Either your program works and you are done, or else you have some problems and you don't know why (which is more likely). We have an instructor who is there to help you find those problems, but there's a little more you can do on your own. When you finish this course you will be in the same situation: either try to find your problems on your own, or get help. Later we will tell you how to get Java questions answered on the internet.
On your own, there is a "See Tom's Calc" button on the right side of the entry panel, which you can click to see my version of this program. It will be different from yours, but you should be able to see enough similarities to be able to pick out the significant differences. I suggest you copy your program and paste it into a separate window, so you can look at the two side by side.
If my program works and yours does not, one or more of those differences might be the reason. You can slowly, one line at a time, change my program into yours, trying it each time. If you have different names for your variables than mine, be sure to change the names of each variable all at once. When it stops working, you have found the problem. If that doesn't work, get somebody else to look at it. If you have a friend who can come look at your screen (or use Zoom) see if explaining it to them helps. If none of those work, call the instructor over, it's our job to make sure you do not stay stuck.
You may have noticed that we planned on the user pressing the (E)qual key after they entered their second value, but my code doesn't do that. After I got this far, I realized that the Equal button on the pocket calculator is there to tell the program inside that the user has finished typing their number, but we have that built into the input {number} command, because the user must type the Enter key for the computer to accept the number. Sometimes we put something into the design (or leave something out) and later realize our mistake. That's OK. Later, if you decide to re-visit this calculator with a "gooey" (GUI, Graphical User Interface) format, you will need to implement the Enter button.
Similarly, after I got my calculator working, I realized that I really needed to confirm for the user what operation they selected before making them input their value, so if they typed "A" we show "What number would you like to Add:" and so on for the others, but that would add a bunch more lines. You can do that to yours, and then your program would be better, more friendly than mine. Right?
When your program works OK, or if you want to take a break and work on something
different, just save your program text in a separate file (copy the text and paste
it into NotePad or whatever you have for saving text on your computer),
then turn the page to program a game.
<<Previous | ToC | Next >>
[2021 May 27]