Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  ้hw1
Language: JAVA
Code:
import java.util.*;
class hw1
{
 public static void main(String []args)
 {
     Scanner scan = new Scanner(System.in);
        System.out.println("Ax^2+bx+c");
          System.out.println("Enter A : ");
          int a = scan.nextInt();
          System.out.println("Enter B : ");
          int b = scan.nextInt();
          System.out.println("Enter C : ");
          int c = scan.nextInt();
          double x1,x2;
          double ans = Math.sqrt(Math.pow(b,2)-4*a*c);
          x1 = (-b+ans)/2*a;
          x2 = (-b-ans)/2*a;
          System.out.println("ANS1 = "+x1);
          System.out.println("ANS2 = "+x2);
     }
}
Comments: