HW3.3

时间:2022-05-31 16:22:05

HW3.3

HW3.3

 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, d, e, f: ");
         double a = input.nextDouble();
         double b = input.nextDouble();
         double c = input.nextDouble();
         double d = input.nextDouble();
         double e = input.nextDouble();
         double f = input.nextDouble();

         input.close();

         if(a * d - b * c == 0)
             System.out.println("The equation has no solution");
         else
         {
             double x = (e * d - b * f) / (a * d - b * c);
             double y = (a * f - e * c) / (a * d - b * c);
             System.out.println("x is " + x + " and y is " + y);
         }
     }
 }

相关文章