之前有写过这个程序,貌似在第一章节中,现在只需要加循环就好了。看清楚题目要求,就很简单了。 package nameyu;import java.util.Scanner; public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner input=new Scanner(System.in);//先了解下控制台输入函数 System.out.println("please input value for 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(); double x=(e*d-b*f)/(a*d-b*c); double y=(a*f-e*c)/(a*d-b*c); if(a*d-b*c!=0){ System.out.println("The x value is :"+x); System.out.println("The y value is :"+y); }else System.out.println("The equation has no solution"); } }
|