HW3.1

HW3.1

 import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);

         System.out.print("Enter a, b, c: ");
         double a = input.nextDouble();
         double b = input.nextDouble();
         double c = input.nextDouble();

         input.close();

         double delta = b * b - 4 * a * c;

         if(delta > 0)
         {
             double root1 = (-b + Math.pow(delta, 0.5)) / (2 * a);
             double root2 = (-b - Math.pow(delta, 0.5)) / (2 * a);
             System.out.println("The roots are " + root1 + " and " + root2);
         }
         else if(delta == 0)
         {
             double root = -b / (2 * a);
             System.out.println("The root is " + root);
         }
         else
             System.out.println("The equation has no real roots.");
     }
 }
上一篇:Docker入门教程(四)Docker Registry


下一篇:Java Web 学习路线