Question: Open the app that s in the C: C# Ch 0 5 InvoiceTotal directory. Change the if - else statement so customers

Open the app thats in the C:\C#\Ch05\InvoiceTotal directory.
Change the if-else statement so customers of type R with a subtotal that is greater than or equal to $250 but less than $500 get a 25% discount and those with a subtotal of $500 or more get a 30% discount. Next, change the if-else app to make sure this works.
Add another customer type to the if-else statement, so customers of type T get a 40% discount for subtotals of less than $500, and a 50% discount for subtotals of $500 or more. Also, make sure that customer types that arent R, C, or T get a 10% discount. Then, test the app.
Test the app again, but use lowercase letters for the customer types. Note that these letters arent evaluated as capital letters. Now, close the app and modify the code, so the users can enter either capital or lowercase letters for the customer types. Then, test the app to make sure it works correctly.
Use a switch statement with if-else statements to get the same results
Enter the start of a switch statement right after the if-else statement. Next, enhance this code, so the switch statement provides the structure for handling the three cases for customer types: R, C, and T (but not r, c, and t). Then, within each of these cases, you can copy the related code from the if-else statement above to provide for the discounts that are based on subtotal variations. In other words, the if-else statements will be nested within the switch cases.
Comment out the entire if-else statement above the switch statement. Then, test to make sure the switch statement works correctly. Is this code easier to read and understand?
Use a switch expression
Comment out the entire switch statement. Then, enter a switch expression that sets the discount percent to 30% for the R customer type, 20% for C, and 50% for T with a default discount percent of 10%.
Test to make sure the switch expression works correctly. Is this code shorter and easier to read than a comparable switch statement?
Close the project.

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!