Chapter Table of Contents
Section Table of Contents
- Chapter Table of Contents
- Section Table of Contents
- Even or Odd?
- Old Enough to Drive?
- Enhance Billing Project
- Pick Your Path
- Previous Section
- Next Section
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.
Even or Odd?
Use the modulus operator (%) to check whether an inputted number is even or odd.
Old Enough to Drive?
Create a program called Drive
In the main method, 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+.
- Use the boolean expressions to print the age group the user is in.
- Use the boolean expressions to print whether the user can drive. An adult or senior can drive, while a minor cannot.
Enter your age: 45 You are an adult. Old enough to drive!
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).
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.
Pick Your Path
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.