Question: #include #include #include using namespace std; int main() { float maximum=0; float discount=0; float discountpercent=0; float price=0; float total=0; float Gtotal=0; float available=0; int item=0;

#include

#include

#include

using namespace std;

int main()

{

float maximum=0;

float discount=0;

float discountpercent=0;

float price=0;

float total=0;

float Gtotal=0;

float available=0;

int item=0;

int many=0;

int count=0;

cout << "What is your maximum to spend?" << endl;

cin >> maximum;

available=maximum;

while (Gtotal < maximum)

{

cout << "You have $ " << available << " dollars to spend. Select your items by choosing the number of the item from the list below or 0 to check out." << endl;

cout << "1) Roses = $75.00 per 1/2 dozen (25% discount)" << endl << "2) Hair extentions = $100 per pack (10% discount)" << endl << "3) Male Jeans = $150.00" << endl << "4) Female Jeans = $175.00 (5% discount)" << endl << "5) Jordans = $200.00" << endl << "0) proceed to check out" << endl;

cout << "Enter the number corresponding to the item you desire" << endl;

cin >> item;

if (item == 0){

Gtotal=maximum+1;

break;

}

else

{

if (item == 1){

item=75;

cout << "How many of this item would you like?" << endl;

cin >> many;

item=many*item;}

else

if (item == 2){

item=100;

cout << "How many of this item would you like?" << endl;

cin >> many;

item=many*item;}

else

if (item == 3){

item=150;

cout << "How many of this item would you like?" << endl;

cin >> many;

item=many*item;}

else

if (item == 4){

item=175;

cout << "How many of this item would you like?" << endl;

cin >> many;

item=many*item;}

else

if (item == 5){

item=200;

cout << "How many of this item would you like?" << endl;

cin >> many;

item=many*item;}

}

cout << "Does this item have a discount? Enter 1 for YES and 2 for NO." << endl;

cin >> discount;

if (discount==1){

cout << "What is the % of the discount?" << endl;

cin >> discountpercent;

price=item * (discountpercent/100);

price= item - price;

}

else

price=item;

count= count + many;

total= price + price * 0.07;

if (total>available){

cout << "You only have" << available << "You cannot make this purchase." << endl;

total=0;

count= count-many;

}

Gtotal=Gtotal +total;

cout << "You have " << count << " items in your cart. Your cost is $ " << Gtotal << "."<< endl;

cout << "--------------------------------------------------------------" << endl << endl;

available= maximum-Gtotal;

}

return 0;

}

How to change this program into a function?

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!