Selection: Spring 2024
Learning Objective(s)
- Learn to use selection
- Write your first program
- Learn to work with strings, characters, and integers
Overview of the Program
For this program you are to get the user to enter two numbers, an operation, and what they think the answer is. The program should then compute the answer and tell the user if they are correct.
Specifics
- The program should be called Arithmetic.java
- All arithmetic is to be integer arithmetic
- The user is to input a +, -, *, or / to indicate what operation
- If a wrong operation is given, the program should inform the user that a wrong operation was given.
Sample dialogue
Below is a sample dialogue. Your output can vary somewhat as long as the required data is nicely displayed
What is the first number? 5
What operation (+, -, *, /)? +
What is the second number? 7
What do you think the answer is? 15
You did not get it right.
You can also run a solution for this program if you want. See classroom instructions for more details.
Submission
- Create your SDR.
- In Lessons Learned, include a discussion on how the operation was inputted and handled.
- If you used any hints, be sure to indicate that in the Outside Resources Used section
- Convert your SDR into a pdf document
- Create an empty zip folder
- Place your java file and pdf document in it.
- Submit the zip folder on canvas
Hints
- Algorithm hint
- Handing the operation
Optional improvements
Optional improvements should ONLY be worked on once the program is completing working. In addition, the work is to be done on your own with little if any help for lab assistants or the instructor.
- Use a switch statement to decide what operation to compute