import java.util.Scanner;
public class test {
public static void main(String[] args) {
int a,b,c,delta;
//float x1,x2;
System.out.println("Nhap a, b, c: ");
Scanner input = new Scanner(System.in);
a = input.nextInt();
b = input.nextInt();
c = input.nextInt();
delta = b*b - (4*a*c);
if (a==0)
{
if (b==0)
{
if (c==0)
System.out.println("Phuong trinh co vo so nghiem!");
else
System.out.println("Phuong trinh vo nghiem!");
}
else
System.out.println("Phuong trinh co nghiem :"+((float)-c/b));
}
else if (a!=0)
{
if (delta<0)
System.out.println("Phuong trinh vo nghiem!");
else if (delta==0)
System.out.println("Phuong trinh co nghiem kep: "+((float)-b/(2*a)));
else
{
System.out.println("Phuong trinh co nghiem x1= "+(((float)-b-Math.sqrt(delta))/(2*a)));
System.out.println("Phuong trinh co nghiem x2= "+(((float)-b+Math.sqrt(delta))/(2*a)));
}
}
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.