gptrb2 java

Màu nền
Font chữ
Font size
Chiều cao dòng

/**

* @(#)gpt2.java

*

*

* @author

* @version 1.00 2009/10/14

*/

import javax.swing.JOptionPane;

public class gpt2 {

public static void main(String args[]) {

float a,b,c,delta;

a=Float.parseFloat(JOptionPane.showInputDialog(" nhap a : "));

b=Float.parseFloat(JOptionPane.showInputDialog(" nhap b : "));

c=Float.parseFloat(JOptionPane.showInputDialog(" nhap c : "));

if (a==0){

System.out.println("pt da cho la pt bac nhat!");

if(b==0){

if(c==0){

System.out.println("pt vo so nghiem! ");

}

else {

System.out.println(" pt vo nghiem ");

}

}

else {

System.out.println("pt co 1 nghiem duy nhat : " + ((-c)/b));

}

}

else {

System.out.println((" la pt bac 2 "));

delta=b*b-4*a*c;

if(delta==0){

System.out.println(" pt co nghiem kep : " + (-b/(2*a)));

}

else {

if(delta<0){

System.out.println("pt vo nghiem !");

}

else {

System.out.println("pt co 2 nghiem pb:" + ((-b+Math.sqrt(delta))/(2*a))+ ((-b+Math.sqrt(delta))/(2*a)));

}

}

}

}

}

Bạn đang đọc truyện trên: Truyen2U.Pro