5οΈβ£

6.5 Practice

π€
Ch. 6 Conditionals

Practice

Create a class called Grade. In the main method, prompt the user to enter a test score as a percent. Then, print out the letter grade that that score would receive.
π» Template code
Β

Even or Odd?

Use the modulus operator (%) to check whether an inputted number is even or odd.
π» Template code
Β

Old Enough to Drive?

Create a program called Drive. It should do the following:
• Prompt the user to enter their age
• Create 3 boolean expressions isMinor, isAdult, and isSenior. A person is a minor if they're under 18. They are an adult if they're 18-64 years old. They are a senior if they're 65+.
• Print the age group the user is in.
• Print whether the user can drive. An adult or senior can drive, while a minor cannot.
Β
Example output:
``````Enter your age: 45
Old enough to drive!``````
π» Template code
Β

Enhance Billing Project

Adjust the billing project so that the program asks the user the name of the item and the price of the item. Next, if the price is greater than \$10, then apply a 5% off discount, otherwise if the price is greater than \$25, apply a 10% off discount. Then print the name of the item, original price, discount amount, subtotal (discounted price), tax (8% of the discounted price), and total (subtotal + tax).
Β
Example output:
``````Enter the name of the item: Pizza
Enter the price of the item: \$12

RECEIPT
Item: Pizza
Price: \$12.00
Discount \$0.60
---------------------
Subtotal: \$11.40
Tax: \$0.96
Total: \$12.36``````
Β
β οΈ
In order to achieve the output above, you will need to use String formatting to ensure that monetary amounts are displayed to 2 decimals of precision. You can read more about that here. If you donβt know how to use String formatting, thatβs ok too, just print things normally.
π» Template code
Β

Create a simple pick your path game where you give the user a scenario and different actions they can take. You should have at least 3 scenarios. Use your imagination to think of something cool! Below is a video example for the pick your path program.
π» Template code
Β

4οΈβ£
6.4 If and Else

β
Chapter 6 Quiz
Β
βοΈ