Hint to determining the operation (Selection lab: Fall 2023)
You have two options:
- Get the operation as a string and then just work with the first character
- For this operation, get the string
- Then use the charAt string function to get the first character (number 0) and assign it to a character variable
- You can use a switch statement on a character variable
- Get the operation as a string and use that
- This operation requires the user to be very precise on the input. If the user adds another blank at the end, this might cause a problem.
- If you use this option, be sure to use .equals in your selection statement
- You cannot use a string in a switch statement.
For either option, it is best to read the string as an entire line.
This topic: CenterForComputing
> WebHome >
Syllabi >
CSC121SylF2023 >
CSC121F2023Lab02 > CSC121F2023Lab02Hint2
Topic revision: r1 - 2023-06-09 - cathybareiss