fork download
  1. import java.io.*;
  2. public class Quadratic.java
  3. {
  4. public static void main(String[] args) throws IOException
  5. {
  6. String str1,str2,str3;
  7. int a,b,c,d;
  8. double x1,x2;
  9. System.out.println("Enter the value of a,b,c");
  10. str1=br.readLine();
  11. str2=br.readLine();
  12. str3=br.readLine();
  13. a=Integer.parseInt(str1);
  14. b=Integer.parseInt(str2);
  15. c=Integer.parseInt(str3);
  16. d=(b*b)-(4*a*c);
  17. System.out.println(d);
  18. if(d==0)
  19. {
  20. x1=(-b/(2*a));
  21. x2=x1;
  22. System.out.println("Roots are real and equal");
  23. System.out.println("root1="+x1);
  24. System.out.println("root2="+x2);
  25. }
  26. else if(d<0)
  27. {
  28. x1=(-b/(2*a));
  29. x2=(Math.sqrt(-d)/(2*a));
  30. System.out.println("roots are imaginary");
  31. System.out.println("root1="+x1+"+j"+x2);
  32. System.out.println("root2="+x1+"-j"+x2);
  33. }
  34. else if(d>0)
  35. {
  36. x1=((-b)+Math.sqrt(d)/(2*a));
  37. x2=((-b)-Math.sqrt(d)/(2*a));
  38. System.out.println("Roots are real and distinct");
  39. System.out.println("root1="+x1);
  40. System.out.println("root2="+x2);
  41. }
  42. else
  43. {
  44. System.out.println("roots cannot be found");
  45. }
  46. }
  47. }
  48.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:2: error: '{' expected
public class Quadratic.java
                      ^
1 error
stdout
Standard output is empty