Java语言程序设计基础篇编程练习题3.3示例代码

import java.util.Scanner;
public class Test3_03 {
	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();
		
		double criterion = a * d - b * c;
		
		if(criterion == 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);
		}
	}
}

 

你可能感兴趣的:(Java语言程序设计基础篇编程练习题3.3示例代码)