After a relatively small C++ background, I decided to learn some Java. I want to be able to pass two variables from my main class, evaluate them in another class, and return that answer to the main class. I have all the code done for it pretty much, but I can't figure out how to use the returned variable in my main class. Any help would be appreciated!
I just tried adding a "System.out.println(answer)" in the case inside the switch statement, but I got an error saying that "answer cannot be resolved to a variable." I'm sure this is a quick fix, but I couldn't find anything helpful by googling it, so any help would be awesome.
You have fallen into a trap which lots of people fall into. You are writing too much code all in the same place. You are going to write enter 1st number enter 2nd number four times. That is not at all good style. That ought to be moved somewhere else. A separate method. Maybe even in a separate class. Create an Arithmetic class with two fields for the two numbers, and sum() difference() product() quotient() (=divide) and remainder() methods.