Monday, 15 March 2010

java - My conditional isn't working, i'm a beginner programmer -


  double A = 10; // 10 dollars to spend double b = 0, // double the cost of that meal; // Final Total Double D; // amount of sandwich c = ab; String order; Scanner sc = new scanner (System.in);  

And it is that I am trying to do my purpose to get the number of sandwich and multiply it; While the number is 2 or less, she says that one thing is 3 or more. The problem is that I'm being asked to start the variable with 0, but obviously, d * 0 is still zero.

  System.out.println ("This will be 1.06, how much do you want?"); B = 1.06 * d; D = sc.nextDouble (); System.out.println (d & lt; = 2? "OK! Sir is coming up!": "... well ... maybe he thinks that you're a fat now."); System.out.println ("He hands you back" + (A-B) + "as your change"); break;  

The problem is here:

  System Out. Println ("How will you like this will be 1.06?"); B = 1.06 * d; D = sc.nextDouble ();  

You have not started d , so when you multiply your multiplication you are not multiplying by b Before multiplying, you have to load the value of the scanner in the d .

  System.out.println ("How many would you like it will be 1.06?"); D = sc.nextDouble (); B = 1.06 * d;  

No comments:

Post a Comment