Practice With if Statements
Letter grade exercise
- The problem: obtain numeric grades and transform them into letter grades. For example:
| Numeric range | Letter grade as output
|
|---|
| 100-90 | A
|
| 89-80 | B
|
| 79-70 | C
|
| 69-60 | D
|
| 59..below | F
|
|
- First:
- Ask the user ONLY ONCE for a number between
0 and 100 and output the corresponding
letter grade. Remember that if you test their
input 100 >= x >= 90 you have to do it in two
steps: (100 >= x) && (x >= 90)
- Now that it compiles and works ask the
user for several numbers until the user enters -1
then stop.
- Hint: here you use loops... figure out the
condition carefully and what goes in the body of
the loop before writing the program.