posted 1 year ago
Hey I am stuck on this homework assignment and really need help. I am suppose to print out two random numbers and the bigger number is suppose to subtract the smaller number. Yet when the smaller number subtracts the bigger number it also outputs the smaller number subtracting the bigger number. Not only that but I need a response for the user to solve the problem and if the answer is correct I then want it to display saying correct. If not I want it to display incorrect with what the problem was and the actual answer. The following is what I have so far. Thanks!!!
posted 1 year ago
In future, while posting code, please UseCodeTags
I have added them this time for you. As you can see the tags make the code much more readable and easy to understand.
Consider this line of code
Do you see what is wrong here?
So you have
1) Generated two random numbers (By the way check out Random#nextInt(int bound);)
2) Posed the question to the user
TODO
3) Figure out what the user answered
4) Evaluate the answer
5.a) If correct, display "correct"
5.b) If not, display "incorrect" and explanation
So do you know how to go about step 3? If not check out https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html
I have added them this time for you. As you can see the tags make the code much more readable and easy to understand.
Junaid Mahmud wrote:Yet when the smaller number subtracts the bigger number it also outputs the smaller number subtracting the bigger number.
Consider this line of code
Do you see what is wrong here?
Junaid Mahmud wrote:Not only that but I need a response for the user to solve the problem and if the answer is correct I then want it to display saying correct. If not I want it to display incorrect with what the problem was and the actual answer.
So you have
1) Generated two random numbers (By the way check out Random#nextInt(int bound);)
2) Posed the question to the user
TODO
3) Figure out what the user answered
4) Evaluate the answer
5.a) If correct, display "correct"
5.b) If not, display "incorrect" and explanation
So do you know how to go about step 3? If not check out https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html
Get out of my mind! Look! A tiny ad!
The WEB SERVICES and JAXRS Course
https://coderanch.com/t/690789/WEBSERVICESJAXRS
