Problem 04:
Write a program
that display the result of quadratic formula
Description:
By using
Math.sqrt();
Solution:
import java.util.*;
public class Message {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double a,b,c,x;
System.out.println("Enter the value of
a b
and c");
a=in.nextDouble();
b=in.nextDouble();
c=in.nextDouble();
x = (-b+Math.sqrt(b*b-(4*a*c)))/ (2*a);
System.out.println("The final result is
= "+x);
}
}
Output
No comments:
Post a Comment