Chapter Table of Contents

Ch. 9 Arrays

Section Table of Contents

Practice

Grade Enhancement

Create a program called Grade which prompts the user for the number of test scores to be entered and then prompts the user to enter those scores. Then your program should print the letter grades that correspond to each score. (Use a char[] array to store the letter grades.)

Sample output:

Enter the number of test score: 5
Enter score 1: 3
Enter score 1: 61
Enter score 1: 100
Enter score 1: 87
Enter score 1: 75

Grades:
F D A B C

💻 Template code

Solution code

Billing Enhancement

Create a program called Billing which prompts the user for the number of items they will enter. Then ask the user for the name of the item and price repeatedly. Once the last item and its price has been entered, print a receipt which has each item and its price, as well as the subtotal, tax, and total. (The sales tax rate is 8%.) Hint: Use an array to store the item names and prices.

Sample output:

Enter the number of items: 3
Enter item #1: shirt
enter the price of item #1: $15.43
Enter item #2: pants
enter the price of item #2: $12.38
Enter item #3: hat
enter the price of item #3: $4.99

RECEIPT
-----------------------------------
shirt - $15.43
pants - $12.38
hat - $4.99
-----------------------------------
Subtotal: $32.80
Tax: $2.62
Total: $35.42

<aside> 💡 Hint: You may encounter a problem when using Scanner. Read the following article for a solution: Debugging Scanner Skipping Problem

</aside>

💻 Template code

Solution code