Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Task1
- {
- public static void main(String args [])
- {
- Scanner sc = new Scanner(System.in);
- double A, B, C;
- System.out.println("Enter A = ");
- A = (int) Math.round(sc.nextDouble());
- System.out.println("Enter B = ");
- B = (int) Math.round(sc.nextDouble());
- System.out.println("Enter C = ");
- C = (int) Math.round(sc.nextDouble());
- System.out.println("A :"+A+ '\n' +"B :" +B+ '\n'+"C :" +C +'\n');
- double delta ;
- double deltaRoot;
- double x1 =0;
- double x2 =0;
- delta = ( B*B) - (4*A*C);
- deltaRoot = Math.sqrt(delta);
- if(A == 0)
- {
- System.out.println("A NEED TO BY GREATER THAN 0" );
- }
- if(delta == 0)
- {
- x1 = (-B)/(2*A);
- }
- else if (delta > 0)
- {
- x1 = (((-1)*B - deltaRoot)/(2*A));
- x2 = (((-1)*B + deltaRoot)/(2*A));
- }
- else
- {
- System.out.println("No SOLUTION MEN ");
- }
- System.out.println("DELTA = " + delta+'\n'+ "DELTAROOT = " +deltaRoot+'\n');
- System.out.println(x1+""+'\n'+x2+'\n');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement