The Acme Software Company sells its "Adding Tutor" software for \$109.Quantity discount are given using the following table:
Quantity Discount
10-19 20%
20-49 30%
50-99 40%
100 or more 50%
Write a program that asks for the number of units sold and calculates the total cost of the purchase including discount. Adjust the totalby the sales tax (use 7.75%). Display the total cost, the discount, the sales tax and adjusted amount due. Display a warning and end the program if the number of units sold isnot greater than 0
I have finish but I couldn't calculate and it not work..Can anyone help me please

I have finish but I couldn't calculate and it not work

Show us what you've got done so far, so we know what to tell you to correct.

This is what I got so far. Plese help out. I don't know how to do it. I really need help.

``````//PREPROCESSOR DIRECTIVE
# include <iostream>   //FOR CIN AND COUT
# include <iomanip>
# include <string>

using namespace std;

//Main Function

int main()

{
//Define Variables
int      Quantity;            //  QUANTITY OF ITEMS

float    Cost;                //  SALES ITEMS
float	 Discount;          //  DISCOUNT MONEY
float	 TaxRate;           // SALE TAXES
float	 TotalCost;	        // TOTAL AMOUNT FOR EACH ITEM
float	 AdjustAmount;      // THE AMOUNT DUE

//DEFINE CONSTANTS
const double DiscountRate1= 0.00f;    //Rate CODES
const double DiscountRate2= 0.20f;
const double DiscountRate3 = 0.30f;
const double DiscountRate4 = 0.40f;
const double DiscountRate5 = 0.50f;

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

cout << "\n\nThe Acme Software Company";  //PROGRAM TITLE
cout << "\nby Kristen Ngoc, Nguyen";      //PROGRAM AUTHOR

//ASK USER FOR THE AMOUNT OF UNITS YOU WANT TO PURCHASE

cout << "\n\nPlease enter the units you want to purchase:";    //INPUT DATA FOR UNITS
cin  >> Quantity;

//TEST IF QUANTITY IS GREATER THAN 0
if (Quantity >= 0)
{
//DETERMINE THE DISCOUNT RATE

if (Quantity <10 )
{

Cost = Quantity * 109;
Discount = Cost * DiscountRate1;
TotalCost = Cost - Discount;
TaxRate = TotalCost *0.0775f;
}

else if (Quantity <20)
{

Cost = Quantity * 109;
Discount = Cost * DiscountRate2;
TotalCost = Cost - Discount;
TaxRate = TotalCost *0.0775f;
}
else if (Quantity <50)
{

Cost = Quantity * 109;
Discount = Cost * DiscountRate3;
TotalCost = Cost - Discount;
TaxRate = TotalCost *0.0775f;
}
else if (Quantity <100)
{

Cost = Quantity * 109;
Discount = Cost * DiscountRate4;
TotalCost = Cost - Discount;
TaxRate = TotalCost *0.0775f;
}
else
{

Cost = Quantity * 109;
Discount = Cost * DiscountRate5;
TotalCost = Cost - Discount;
TaxRate = TotalCost *0.0775f;

}

//DISPLAY RESULTS

cout << fixed << showpoint << setw (20);
cout <<"\nSales Results\n";
cout <<"- - - - - - - - - - \n";
cout <<"\n" << setw(20) << "Cost \$" << "Cost" << endl;
cout <<"\n" << setw(20) << "Discount rate " << "DiscountRate" << endl;
cout <<"\n" << setw(20) << "Discount \$" << "Discount" << endl;
cout <<"\n" << setw(20) << "Total Cost \$" << "TotalCost" << endl;
cout <<"\n" << setw(20) << "Sales Taxes \$" << "TaxRate" << endl;
cout <<"\n" << setw(20) << "Adjust Amount \$" << "AdjustAmount" << endl;

}

else

cout << "Invalid entry\n";
return 0;
}``````

In all cases remove quotes around bolded section

``cout <<"\n" << setw(20) << "Adjust Amount \$" << [b]"AdjustAmount"[/b] << endl;``

Declare DiscountRate in your application and set its value inside each conditional

``cout <<"\n" << setw(20) << "Discount rate " << DiscountRate << endl;``

As you've gotten it 95% right, I will post a modified version of this app that you can use as a reference. Don't use it as your assignment or your instructor may get you to explain why you did it that way.

Can you help me make it look right. Because When I did it. It not show the calculation at all. So I think that's not right so we have to use switch or something. Thanks for you help. It due today. It hard when it run.

Ok as promised here is my modification based on your algorithym

``````# include <iostream>
# include <iomanip>
# include <string>
using namespace std;
int main()
{
int Quantity, Disc;
double Cost, Discount, SalesTax;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "\n\nThe Acme Software Company\nby Kristen Ngoc, Nguyen"; //PROGRAM AUTHOR
do
{
cout << "\n\nPlease enter the units you want to purchase: "; //INPUT DATA FOR UNITS
cin >> Quantity;
if (Quantity == 0)
break;
Cost = 109.0 * Quantity;
if (Quantity < 10)
Disc = 0;
else
if (Quantity < 20)
Disc = 20;
else
if (Quantity < 50)
Disc = 30;
else
if (Quantity < 100)
Disc = 40;
else
Disc = 50;

cout << fixed << showpoint << setw (20);
cout <<"\nSales Results\n";
cout <<"- - - - - - - - - - \n";
cout << setw(20) << "Cost" << setw(25) << Cost << endl;
Discount = Cost * (double (Disc) / 100.0);
cout << setw(20) << "Less" << setw(25) << Discount << " " << Disc << "%" << endl;
cout << setw(20) << "Total Cost" << setw (25) << Cost - Discount << endl;
SalesTax = (Cost - Discount) * .0775;
cout << setw(20) << "7.75% Sales Tax" << setw (25) << SalesTax << endl;
cout << setw (45) << "_________________" << endl;
cout << setw(20) << "Total" << setw (25) << Cost - Discount + SalesTax << endl;
} while (1);
return 0;
}``````

Basically all I did with your code is eliminate redundancy. Only have conditionals do what they need to rather than duplicate the same code over and over again.

Please don't label your thread as Urgent-- it implies that your problem is more important than others. Help is given here on a first-come, first-served basis.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.