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#ChInvoiceTotal directory.
Change the ifelse statement so customers of type R with a subtotal that is greater than or equal to $ but less than $ get a discount and those with a subtotal of $ or more get a discount. Next, change the ifelse app to make sure this works.
Add another customer type to the ifelse statement, so customers of type T get a discount for subtotals of less than $ and a discount for subtotals of $ or more. Also, make sure that customer types that arent R C or T get a 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 ifelse statements to get the same results
Enter the start of a switch statement right after the ifelse 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 ifelse statement above to provide for the discounts that are based on subtotal variations. In other words, the ifelse statements will be nested within the switch cases.
Comment out the entire ifelse 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 for the R customer type, for C and for T with a default discount percent of
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
