java - Systems of equations calculator getting "NaN" -


here code.

 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 = 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 = * y;    double fixedequation6 = * 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 " + xanswer); system.out.println("y " + yanswer); 

so code works numbers 2 x 2 equation, when put in values 5,5,5,5,5,5 a,b,c,x,y,z, "nan" want know "nan" mean infinitely many solutions or no solution..

nan means "not number". solution because doing

(25-25)/(25-25) = 0/0, result of undefined, or "not number"


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -