package nambers;
import java.util.Scanner;
public class nambers {
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
System.out.println("type a");
int a=scan.nextInt();
System.out.println("type b");
int b=scan.nextInt();
System.out.println("type c");
int c=scan.nextInt();
int d=(int) (Math.pow(b, 2)-4*a*c);
if (d<0){
System.out.println("no solutions found");
}
else if (d==0){
int sol1=-b/2*a;
System.out.println("solution is only one = "+sol1);
}
else {
int sol2=(int) ((-b+Math.sqrt(d))/2*a);
int sol3=(int) ((-b-Math.sqrt(d))/2*a);
System.out.println("solution one is "+sol2+" solution two is "+sol3);
}
}
}
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.