Advertisement
Mary_99

TASK1 JAVA

Mar 14th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class Task1
  4. {
  5.  public static void main(String args [])
  6.  
  7.     {
  8.      Scanner sc = new Scanner(System.in);
  9.      double A, B, C;
  10.  
  11.      System.out.println("Enter A = ");
  12.      A = (int) Math.round(sc.nextDouble());
  13.      System.out.println("Enter B = ");
  14.      B = (int) Math.round(sc.nextDouble());
  15.      System.out.println("Enter C = ");
  16.      C = (int) Math.round(sc.nextDouble());
  17.      System.out.println("A :"+A+ '\n' +"B :" +B+ '\n'+"C :" +C +'\n');
  18.  
  19.  
  20.  
  21.     double delta ;
  22.     double deltaRoot;
  23.     double x1 =0;
  24.     double x2 =0;
  25.     delta = ( B*B) - (4*A*C);
  26.     deltaRoot = Math.sqrt(delta);
  27.    
  28.  
  29.     if(A == 0)
  30.     {
  31.        System.out.println("A NEED TO BY GREATER THAN 0" );
  32.     }
  33.     if(delta == 0)
  34.     {
  35.         x1 = (-B)/(2*A);
  36.        
  37.      }
  38.    else if (delta > 0)
  39.     {
  40.         x1 = (((-1)*B - deltaRoot)/(2*A));
  41.         x2 = (((-1)*B + deltaRoot)/(2*A));
  42.      }
  43.     else
  44.     {
  45.         System.out.println("No SOLUTION MEN ");
  46.         }
  47.  
  48.       System.out.println("DELTA = " + delta+'\n'+ "DELTAROOT = " +deltaRoot+'\n');
  49.       System.out.println(x1+""+'\n'+x2+'\n');
  50.        
  51.  
  52.  
  53.  
  54.  
  55.     }
  56.  
  57.  
  58.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement