Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2004 Workshops Edbt 2004 Workshops Phd Datax Pim P2panddb And Clustweb Heraklion Crete Greece March 2004 Revised Selected Papers Lncs 3268

Authors: Wolfgang Lindner ,Marco Mesiti ,Can Turker ,Yannis Tzitzikas ,Athena Vakali

2005th Edition

3540233059, 978-3540233053

More Books

Students also viewed these Databases questions

Question

Is the person willing to deal with the consequences?

Answered: 1 week ago

Question

Was there an effort to involve the appropriate people?

Answered: 1 week ago