Hello, I am receiving the error on line 27 that input "type" cannot be resolved this only happens after I have inserted the do-while loop into the program, any ideas on what may be causing this, as the int variable type is clearly defined the line prior.
I realize that you are starting out, but you may want to look into refactoring you code to move the code denoted with //ADD, //SUBTRACT,//MULTIPLY, //DEVIDE and //GENERATE RANDOM NUMBER into separate methods.
Doing this will allow you to separate your code into logical blocks, which can be tested, debugged and programmed separately.
Other benefits of this would code reuse and read ability.
Some people have guidelines that they follow, where if a method is longer then X lines then it's doing too much and it needs to be refactored into different methods.
Some companies enforce the longer then X rule.
“The strongest of all warriors are these two — Time and Patience.” ― Leo Tolstoy, War and Peace
Pete Letkeman wrote:. . . move the code denoted with //ADD, //SUBTRACT,//MULTIPLY, //DEVIDE and //GENERATE RANDOM NUMBER into separate methods.
. . .
Good point. You have lots of repeated code, for example, several places where you enter each number. Also please delete the comments, tha don't tell us anything which isn't already obvious from reading the code.
Even if you declare variable : 'input' and 'type' at line 10 or after declaring variables : 'input' and 'type' at line 10, then also it is entering in an infinite do..while loop and its keep on asking : "Select the calculation you would like to perform" whether you enter 1 or 2 or 3 or 4 or 5. Therefore you need to consider your do.. while loop properly.
Fire me boy! Cool, soothing, shameless self promotion: