Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ch5ex11;
- import java.util.Scanner;
- public class Ch5Ex11
- {
- public static void main(String[] args)
- {
- Scanner sc=new Scanner(System.in);
- System.out.print("Enter the value for a: ");
- int a=sc.nextInt();
- System.out.print("Enter the value for b: ");
- int b=sc.nextInt();
- System.out.print("Enter the value for c: ");
- int c=sc.nextInt();
- double root1=(-b+(Math.sqrt((b*b)-(4*a*c))))/(2*a);
- double root2=(-b-(Math.sqrt((b*b)-(4*a*c))))/(2*a);
- System.out.println("The roots are "+root1+" and "+root2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement