Advertisement
KeeganT

Ch5Ex11

Feb 15th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. package ch5ex11;
  2. import java.util.Scanner;
  3.  
  4. public class Ch5Ex11
  5. {
  6.     public static void main(String[] args)
  7.     {
  8.         Scanner sc=new Scanner(System.in);
  9.         System.out.print("Enter the value for a: ");
  10.         int a=sc.nextInt();
  11.         System.out.print("Enter the value for b: ");
  12.         int b=sc.nextInt();
  13.         System.out.print("Enter the value for c: ");
  14.         int c=sc.nextInt();
  15.         double root1=(-b+(Math.sqrt((b*b)-(4*a*c))))/(2*a);
  16.         double root2=(-b-(Math.sqrt((b*b)-(4*a*c))))/(2*a);
  17.         System.out.println("The roots are "+root1+" and "+root2);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement