Question: C++ Also, instead of having case statements for both upper and lower case letters, use the tolower method to make the users customer_type entry to

C++

Also, instead of having case statements for both upper and lower case letters, use the tolower method to make the users customer_type entry to lowercase, then only check for the lowercase letter in the case statement. Remove any unused/commented out code.

#include #include /*Jared Bartlett CSC-134-OA1*/

using namespace std;

int main() { // display title cout << "The Invoice Total Calculator 2.0 ";

// get input char customer_type; cout << "Enter customer type (r/w/n/c): "; cin >> customer_type;

double subtotal; cout << "Enter subtotal: "; cin >> subtotal;

// set discount percent double discount_percent; switch (customer_type) { // RETAIL case 'r': case 'R': if (subtotal < 100) { discount_percent = .0; } else if (subtotal >= 100 and subtotal < 250) { discount_percent = .1; } else if (subtotal >= 250 and subtotal < 500) { discount_percent = .2; } else { discount_percent = .3; } break; // WHOLESALE case 'w': case 'W': if (subtotal < 500) { discount_percent = .4; } else { discount_percent = .5; } break; // non-profit case 'n': case 'N': discount_percent = .3; break; // COLLEGE case 'c': case 'C': discount_percent = .25; break; // OTHER default: discount_percent = .0; break; }

// calculate and round results double discount_amount = subtotal * discount_percent; discount_amount = round(discount_amount * 100) / 100;

double invoice_total = subtotal - discount_amount; invoice_total = round(invoice_total * 100) / 100;

// display output cout << "Discount percent: " << discount_percent << endl << "Discount amount: " << discount_amount << endl << "Invoice total: " << invoice_total << endl << endl;

cout << "Bye! "; }

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 Databases Questions!