Challenge 1 - Grocery Store Checkout System

Programming Problem: Grocery Store Checkout System

You are tasked with creating a simple Grocery Store Checkout System. The system will take user inputs for items and their prices, calculate the total cost, and apply discounts based on certain conditions.

Requirements:

  1. User Input:

    • The system should ask the user how many items they want to purchase.

    • For each item, the system should ask for the name and price of the item.

    • Store the item names and prices in separate lists.

  2. Conditional Statements and Relational Operators:

    • If the total cost of all items exceeds $100, apply a 10% discount.

    • If the total cost is between $50 and $100 (inclusive), apply a 5% discount.

    • No discount is applied if the total cost is less than $50.

  3. Iteration Statements and List Operations:

    • Use a loop to iterate over the items and calculate the total cost.

    • Use nested loops if necessary to check and apply the discounts.

  4. String Manipulation:

    • The system should output the list of items with their prices in a formatted string.

    • Ensure proper formatting for currency (e.g., two decimal places).

  5. Display Output:

    • Display the total cost before and after applying any discounts.

    • Display the total savings if a discount is applied.

Sample Output:

Enter the number of items you want to purchase: 3
Enter the name of item 1: Milk
Enter the price of Milk: 2.99
Enter the name of item 2: Bread
Enter the price of Bread: 1.50
Enter the name of item 3: Eggs
Enter the price of Eggs: 3.00

Items purchased:
1. Milk - $2.99
2. Bread - $1.50
3. Eggs - $3.00

Total cost before discount: $7.49
No discount applied.
Total cost after discount: $7.49

Your Task:

Implement the Grocery Store Checkout System in Java. Make sure your code is well-commented and follows best practices for readability and maintainability.

Tips: