Lab 3
if loops and calculator program
Lab 3_1 (if loop) - 10 points
- Project name: yourname3_1
- cpp file name yourname3_1
- Create a program that has one integer
- Let the user input a number
- Test whether the number is greater than, less than, or equal to 100
- Output a message that tells the user whether the number is greater or less
than 100 (Hint: you'll have three "if" loops that will display different
messages.
- Get your pseudocode OK'ed by Mrs. Sanchez before you begin to write your
code
Lab 3_2 if loops with char variables - 10 points
- Project name: yourname 3_3
- cpp filename: yourname 3_3
- Create a program that allows the user to input something into a character
variable. Your user should have the choice of two options: (Y and N)
- If the user selects Y, output a message of your choice
- If the user selects N, output a different message
Lab 3_3 (increment and decrement operators) - 10 points
- Project name: yourname 3_2
- cpp file name: yourname 3_2
- Copy the code from the increment/decrement code example on the Programming
web page. (After you create a new C++ source file, paste the text from the
Web site into the programming window. Voila! The program is "written."
- Compile and run the program
- Add comments to the program that explain what the increment (++) and decrement
(--) operators are doing
Calculator - 20 points
- Project name: yourname_calc
- cpp file name: yourname_calc
- Using the pseudocode we wrote last week, write the part of the program that
will allow the user to input three numbers. Add some cout messages to verify
the input back to the screen.
- Add a section that will ask the user whether they want to add, multiply,
divide, or subtract. You should add a character variable (char) to hold this
value. The user could enter a math symbol (+, -, *, /) or you can ask then
to enter A for add, S for subtract, D for divide, or M for multiply)
- Display the user's choice back to the screen.
- We'll add the "if" loops next week
Enrichment
(extra credit, but required if you finish your work before the
rest of the class)
If you finish with the assignments above, you should do the following problems
for extra credit:
- Project and CPP file name: yourname_3EC1
- Your teacher gives you three assignments worth 50 points each. You can drop
one of the first two grades. The final grade i the sum of the best of the
first two grades and the third grade. Write a program that inputs three test
grades, then calculates the final grade using the following cut-off points.
|
>= 90
|
A
|
|
< 90, >=80
|
B
|
|
<80, >= 70
|
C
|
|
< 70, >=60
|
D
|
|
< 60
|
F
|
- Note: This program may use nested loops (if statements built inside of if
statements)
- It will be VERY helpful to write pseudocode for this. You may work together
to write your pseudocode, but each person should write their own program.