• Post Reply Bookmark Topic Watch Topic
  • New Topic

Assistance with Math program task Java  RSS feed

 
Josh Brand
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Hi all! I need to create a class that outputs the following;

"Welcome to the Calculator"
Number of questions: 5

Question 1: 5 + 10 = 15 Correct!
Question 2: 6 * 12 = 82 Incorrect
Question 3: 10 - 12 = -2 Correct!
Question 4: 20 + 17 = 37 Correct!
Question 5: 10 / 15 = 5 Incorrect!

The process for completing this checkpoint is to define a loop that will iterate from 0 to numQuestions. At each iteration a random number should be generated between 1 and 4. The number generated will determine what the operation should be: 1 – add, 2 – subtract, 3 – multiply, and 4 – divide.

Depending on the operation the appropriate method should be invoked. The execution of the method should be the same as in the previous checkpoint, ie. output a string of the operations on the output window, then return the result to the calling code.

Within session you should collect user input and compare that input to the result returned from the previous step. If the user input and the program generated result are the same then output "Correct!" if they do not match then output "Incorrect".

My main issue is I am trying to store information in an array to then print but with no success.



 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you know, we don't provide complete solutions.

Were you given that class, or did you write it? The constructor and session() method are incorrect. Please show us what you have done with the array, and explain what problems you are having with it.
 
Josh Brand
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We were given the methods but I created the functions of the methods. I am essentially trying to print the array at said point
 
Paul Clapham
Sheriff
Posts: 22821
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you say you were trying to store information in an array?



This isn't the way to store information in an array entry. It's the way to get information out of an array entry. I'd suggest you go back to whatever source you're learning from and review what the "=" operator does.


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!