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 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: $ Phone: $ o Clothing: Tshirt: $ Jeans: $ o Groceries: Apples per kg: $ Bread: $ Requirements: User Input: o The user will input their choice of category using a number for Electronics, for Clothing, 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 ifelse statements to apply a discount of if the total purchase exceeds $ 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 Operators: o Use appropriate arithmetic operators for calculations. o Use relational and logical operators for comparisons eg checking if total is above $ for a discount Questions: a Write a java program based on the given scenario above. Marks b Explain the role of each operator used in the program, including arithmetic and relational operators. Marks c Why is a switch case used in this program, and how does it simplify decisionmaking compared to multiple ifelse statements? Marks d Explain how the loop in the program works. What type of loop is used, and why is it suitable in this context? Marks e What would happen if you removed the ifelse structure that applies a discount? Provide a code snippet showing this change and explain the impact on the total bill calculation. Marks f Write an alternative version of the product selection using nested ifelse statements instead of a switch case. How does this change affect the readability of the program? Marks
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
