COMP 110 Summer 2012
TIPS for Program 2: GUI Calculator
- Write out what you want to do in pseudocode before you program.
- Compile your program often.
- Test your code as you go by using JOptionPane.showMessage(null, what you are testing) Things to check:
- input String
- any output from your String methods
- operand1, before and after you convert it to a floating point number
- operand2, before and after you convert it to a floating point number
- anything else you can think of
- You will be able to read in a String from the user input by using something like this:
inputString = JOptionPane.showInputDialog("Please Enter a string:");
- Once you have an input String you need to parse the string (break up your string into groups of characters) into operand1, operator, and operand2
- Use your String methods (p. 78) to parse your String into operand1, operator, and operand2
- You can convert a String to different types (p. 110)
- Remember to use the .equals() method to check if two String
objects hold the same value (instead of ==).