33.5k views
2 votes
Create a program that will ask the user for number of chicken wings or wings they want to order at a restaurant. The number of wings and the sauce will determine if there is a discount on the total wings purchased. For hot wings purchased in a quantity of 6 or less there is no discount. For hot wings and a quantity of more than 6 but less than or equal to 12, there is a 10% discount. For hot wings purchased in the amount of greater than 12 but less than 24 the discount is 20%. For sweet and sour wings, purchased with a quantity of 6 or less the discount is 5%. For sweet and sour wings and a quantity of greater than 6 but less than or equal to 12, the discount is 10%. For sweet and sour wings purchased with a quantity greater than 12 but less than or equal to 24, the discount is 15%. For all wing purchases greater than 24 wings, the discount is 25%. All wings are 50 cents each.

The program needs to ask the user for the type of wing either hot or sweet with the following prompt:
Enter the wing type:
The program also needs to ask for the quantity of wings using the following prompt:
Enter the quantity:
The program needs to determine the discount rate, calculate the subtotal, discount and total cost of the wings. It then needs to print out all of these values using the following text:
Discount Rate:
Subtotal:
Discount:
Total:
Finally the program needs to ask the user if they want to purchase another order of wings using the following prompt:
Enter yes to add another order of wings

1 Answer

1 vote

Answer:

The explanation of this program is given below. This program is written in C++ using dev C++

Step-by-step explanation:

#include <iostream>

using namespace std;

int main()

{ double hotWings=0;//hot wings quantity

double sweetWings=0;// sweet wings quanity

double sourWings=0;// sour wings quanity

double wingPrice=0.50;// wing prices

int wingType=0;//wing type- prompt user to enter wing type

double discount=0.0;// discount

double discountRate=0.0;// discount rate for different wings quanity

double subTotal=0.0;// subtotal wings quantity multiply wing price

string input;

cout<<"Enter the type of Wing 1-for-Hot wings, 2-for-sweet wing and 3-for-sour wing ";// prompt user for input

cin>>wingType;

while(wingType!=4)// while loop until user quit the purchasing

{

switch(wingType)// in the while, decide what type of wing user purchasing

{

case 1:// if user purchase hot wing

cout<<"\\Enter the Quantity ";

cin>>hotWings;

break;

case 2:// if user purchase sweet wings

cout<<"\\Enter the Quantity ";

cin>>sweetWings;

break;

case 3://if user purchase sour wings

cout<<"\\Enter the Quantity ";

cin>>sourWings;

break;

}

if ((hotWings+sweetWings+hotWings)>24)// if all wings is greater than 24

{

discountRate=0.25;// then discount is 25 %

cout<<"\\Discount Rate "<<(discountRate *100)<<"%"; //print discount rate

subTotal=(hotWings+sweetWings+hotWings) * wingPrice;// subtotal

cout<<"\\Subtotal: "<<subTotal;// print subtotal

cout<<"\\Discount:"<<subTotal * discountRate;// print discount on subtotal

cout<<"\\Total: "<<(subTotal-(subTotal * discountRate));// print after discount

}

else if(hotWings<=6)

{

discount=0.0;

cout<<"\\Discount Rate "<<(discountRate *100)<<"%";

subTotal=hotWings * wingPrice;

cout<<"\\Subtotal: "<<subTotal;

cout<<"\\Discount:"<<subTotal * discountRate;

cout<<"\\Total: "<<(subTotal-(subTotal * discountRate));

}

else if(hotWings >6 && hotWings <=12)

{

discountRate=0.10;

cout<<"\\Discount Rate "<<(discountRate *100)<<"%";

subTotal=hotWings * wingPrice;

cout<<"\\Subtotal: "<<subTotal;

cout<<"\\Discount:"<<subTotal * discountRate;

cout<<"\\Total: "<<(subTotal-(subTotal * discountRate));

}

else if(hotWings >12 && hotWings <24)

{

discountRate= 0.20;

cout<<"\\Discount Rate "<<(discountRate *100)<<"%";

subTotal=hotWings * wingPrice;

cout<<"\\Subtotal: "<<subTotal;

cout<<"\\Discount:"<<subTotal * discountRate;

cout<<"\\Total: "<<(subTotal-(subTotal * discountRate));

}

else if(sourWings <= 6){

discountRate=0.05;

cout<<"\\Discount Rate "<<(discountRate *100)<<"%";

subTotal=sourWings * wingPrice;

cout<<"\\Subtotal: "<<subTotal;

cout<<"\\Discount:"<<subTotal * discountRate;

cout<<"\\Total: "<<(subTotal-(subTotal * discountRate));

}

else if(sourWings >6 && sourWings <=12)

{

discountRate=0.10;

cout<<"\\Discount Rate "<<(discountRate *100)<<"%";

subTotal=sourWings * wingPrice;

cout<<"\\Subtotal: "<<subTotal;

cout<<"\\Discount:"<<subTotal * discountRate;

cout<<"\\Total: "<<(subTotal-(subTotal * discountRate));

}

else if(sourWings >12 && sourWings <24)

{

discountRate= 0.15;

cout<<"\\Discount Rate "<<(discountRate *100)<<"%";

subTotal=sourWings * wingPrice;

cout<<"\\Subtotal: "<<subTotal;

cout<<"\\Discount:"<<subTotal * discountRate;

cout<<"\\Total: "<<(subTotal-(subTotal * discountRate));

}

else if(sweetWings<=6)

{

discountRate=0.05;

cout<<"in sweet wing";

cout<<"\\Discount Rate "<<(discountRate *100)<<"%";

subTotal=sweetWings * wingPrice;

cout<<"\\Subtotal: "<<subTotal;

cout<<"\\Discount:"<<subTotal * discountRate;

cout<<"\\Total: "<<(subTotal-(subTotal * discountRate));

}

if(sweetWings >6 && sweetWings <=12)

{

discountRate=0.10;

cout<<"\\Discount Rate "<<(discountRate *100)<<"%";

subTotal=sweetWings * wingPrice;

cout<<"\\Subtotal: "<<subTotal;

cout<<"\\Discount:"<<subTotal * discountRate;

cout<<"\\Total: "<<(subTotal-(subTotal * discountRate));

}

else if(sweetWings >12 && sweetWings <24)

{

discountRate= 0.15;

cout<<"\\Discount Rate "<<(discountRate *100)<<"%";

subTotal=sweetWings * wingPrice;

cout<<"\\Subtotal: "<<subTotal;

cout<<"\\Discount:"<<subTotal * discountRate;

cout<<"\\Total: "<<(subTotal-(subTotal * discountRate));

}

else

{

//nothing

}

cout<<"\\Enter yes to add another order of wings ";

cin>>input;

if(input=="yes"||"Yes")

{

cout<<"\\Enter the type of Wing 1-for-Hot wings, 2-for-sweet wing and 3-for-sour wing and 4-to quit the purchasing";

cin>>wingType;}

else

{

break;

}

}

return 0;

}

User Sahutchi
by
5.0k points