【发布时间】:2015-07-08 04:58:20
【问题描述】:
这是我的代码。
import java.util.Scanner;
import java.util.ArrayList;
public class SysQ {
public static void main(String[] args) {
Scanner keyboard = new Scanner (System.in);
System.out.print("Enter A: ");
double a = keyboard.nextDouble();
System.out.print("Enter B: ");
double b = keyboard.nextDouble();
System.out.print("Enter C: ");
double c = keyboard.nextDouble();
System.out.print("Enter X: ");
double x = keyboard.nextDouble();
System.out.print("Enter Y: ");
double y = keyboard.nextDouble();
System.out.print("Enter Z: ");
double z = keyboard.nextDouble();
double fixedequation2 = x * b;
double fixedequation3 = x * c;
double fixedequation5 = a * y;
double fixedequation6 = a * z;
double final1 = fixedequation2 - fixedequation5;
double final2 = fixedequation3 - fixedequation6;
double yanswer = final2/final1;
double x1 = c - (b * yanswer);
double xanswer = x1/a;
System.out.println("X is " + xanswer);
System.out.println("Y is " + yanswer);
所以代码适用于 2 x 2 方程的大多数数字,但是当我为 a、b、c、x、y、z 输入值 5、5、5、5、5、5 时,我得到“NaN”我只想知道“NaN”是指无限多的解决方案还是没有解决方案..
【问题讨论】: