Question: Question 1 You are tasked with developing a simple online shopping cart system. In this system, users can choose products from three different categories: Electronics,

Question 1 You are tasked with developing a simple online shopping cart system. In this system, users can choose products from three different categories: Electronics, Clothing, and Groceries. Each product category has multiple items, and users can select a quantity for each item. You will calculate the total bill for the user based on their selection and apply a discount if applicable. Product Information: o Electronics: Laptop: $800, Phone: $500 o Clothing: T-shirt: $20, Jeans: $50 o Groceries: Apples (per kg): $3, Bread: $2 Requirements: User Input: o The user will input their choice of category using a number (1 for Electronics, 2 for Clothing, 3 for Groceries). o After selecting the category, the system will display the available products in that category. o The user will choose an item and the quantity they wish to purchase. Control Structures: o Use a switch case to handle the user's category and product selection. o Use if-else statements to apply a discount of 10% if the total purchase exceeds $500. Looping: o After each purchase, the user will be asked if they want to make another purchase (use loops to continue until the user chooses to exit). Note. Provide Screenshots in your word document 4 Operators: o Use appropriate arithmetic operators for calculations. o Use relational and logical operators for comparisons (e.g., checking if total is above $500 for a discount). Questions: a) Write a java program based on the given scenario above. (15 Marks) b) Explain the role of each operator used in the program, including arithmetic and relational operators. (5 Marks) c) Why is a switch case used in this program, and how does it simplify decision-making compared to multiple if-else statements? (7 Marks) d) Explain how the loop in the program works. What type of loop is used, and why is it suitable in this context? (8 Marks) e) What would happen if you removed the if-else structure that applies a discount? Provide a code snippet showing this change and explain the impact on the total bill calculation. (10 Marks) f) Write an alternative version of the product selection using nested if-else statements instead of a switch case. How does this change affect the readability of the program? (5 Marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!