This code generates a random subtraction equation and waits for user input. If input is correct answer it generates another equation until the user gets it wrong. When the user input is wrong, it displays the correct answer and it shows the score (which is the number of correct streaks the user went on before getting it wrong.) I am at the point where the the user gets the answer wrong and the program asks whether the user wants to play again. I am wondering how to make it so if the user types 'y' for yes, the whole program starts from the beginning. Else if he states 'n' for no, the program terminates. Below is my code:
Any tips ?
There are 10 types of people: those who understand binary, and those who do not understand it.
I have finally figured out what I wanted to do and the program works as expected. Although, I would like an experienced pair of eyes to look over the program and tell me if I could improve anything, maybe i have more code than I really need. etc..
So if you see anything, let me know. If it looks good, let me know .
Except before main, where it is needed, remove all occurrences of the keyword static. You will of course have to run the main method slightly differently.
Never use == true or == false. That is poor style and error‑prone because you might write = instead. It is if (b)... or if (!b) ... where “b” means some boolean value or expression.
That method is too long; it ought to be divided into several smaller methods.
The code is only partially indented, and the indentation appears inconsistent. Always use 4 spaces per level (except when you break a single statement over multiple lines) and never use tabs. If you get a decent text editor, you can set it to convert tabs to spaces and set the indentation automatically.