Trouble with c++ assignment

This whole semester, my class has been working on a big program in installments. Well, a couple installments ago, my program wasn't right and I never got help fixing it, so it's just getting progressively more wrong. I tried correcting it more today and I still have to add more tonight, but this is what I have so far. It doesn't even run...

The program is intended to provide two menus in loops, asking the customer if he/she would like to purchase something, which biscuits/dry food he/she would like to purchase, and how many of each. It should give an error message with each incorrect selection. I also have to add a function allowing the users to create their own biscuits. I'm a bit desperate here. Sorry, this thing is giant to me. No idea what I'm doing. This isn't even required for my nursing major...


#include <iostream>
#include <string>
#include <iomanip>

using namespace std;
double const TAX = 1.07;
void getBiscuits (string &biscuitDesc, int &howMany, double &biscuitPrice);
void getDryFood (string &dryFoodDesc, int howMany2, double &dryFoodPrice);
void displayResults (int howMany, string biscuitDesc, double biscuitPrice, int howMany2, string dryFoodDesc, double dryFoodPrice, double &finalTotal);

int main()
{
int howMany = 0;
int howMany2 = 0;
double biscuitPrice = 0;
double dryFoodPrice = 0;
double taxAmount = 0;
double subTotal = 0;
double finalTotal = 0;
char orderBiscuits = 'Z';
char orderDryFood = 'Z';
string fullName = " ";
string biscuitDesc = " ";
string dryFoodDesc = " ";

cout << "Welcome to Buster's Best Biscuits! " << endl;
cout << "Do you want to order some biscuits? (Y/N) " << endl;
cin >> orderBiscuits;

if (toupper(orderBiscuits) == 'Y')
getBiscuits (biscuitDesc,howMany,biscuitPrice);
{
cout << "Please enter your first and last name. " << endl;
cin >> fullName;
cout << "Do you want to order some dog biscuits? (Y/N) " << endl;
cin >> orderBiscuits;
}

cout << "Do you want to order some dry food? (Y/N) " << endl;
cin >> orderDryFood;

if (toupper(orderDryFood) == 'Y')
getDryFood(dryFoodDesc,howMany2,dryFoodPrice);
{
cout << "Do you want to order some dry food? (Y/N) " << endl;
cin >> orderDryFood;
}

if (toupper(orderBiscuits) == 'N' || toupper(orderDryFood) == 'N')
cout << "No chow for you. " << endl;

cout << setprecision(2) << fixed;
displayResults (howMany, biscuitDesc, biscuitPrice, howMany2, dryFoodDesc, dryFoodPrice, finalTotal);

system("pause");
return 0;
}


void getBiscuits(string &biscuitDesc, int &howMany, double &biscuitPrice)
{
int selection = 0;
int numberOfBoxes = 0;
do
{
system("cls");
cout << "Welcome to Buster's Best Biscuits! " << endl;
cout << "******************************************************** " << endl;
cout << "1. Buster's Best Beef Biscuits - $6.00 " << endl;
cout << "2. Puppy Beef Biscuits - $4.50 " << endl;
cout << "3. Buster's Chicken and Peas - $6.00 " << endl;
cout << "4. Puppy Chicken and Peas - $4.50 " << endl;
cout << "5. Medium-sized Chicken and Peas - $6.50 (30 biscuits) " << endl;
cout << "******************************************************** " << endl;
cout << "Please select a number from the menu above. " << endl;
cin >> selection;

if (selection < 1 || selection > 5)
{
cout << "Please select 1 through 5 only. " << endl;
}

while (selection > 1 || selection && selection < 5);
{
cout << "How many of these would you like? " << endl;
cin >> howMany;
}

switch(selection)
{
case 1:
{
biscuitDesc= "Buster's Best Beef Biscuits ";
biscuitPrice = 6.00;
break;
}
case 2:
{
biscuitDesc= "Puppy Beef Biscuits ";
biscuitPrice = 4.50;
break;
}
case 3:
{
biscuitDesc = "Buster's Chicken and Peas ";
biscuitPrice = 6.00;
break;
}
case 4:
{
biscuitDesc = "Puppy Chicken and Peas ";
biscuitPrice = 4.50;
break;
}
case 5:
{
biscuitDesc = "Medium sized Chicken and Peas - 6.50 (30 biscuits) " ;
biscuitPrice = 6.50;
break;
}
default:
{
cout << "You did not enter a valid selection. " << endl;
selection = 0;
}
}
}
}


void getDryFood (string &dryFoodDesc, int &howMany2, double &dryFoodPrice)
{
int selection = 0;
int numberOfBoxes = 0;
do
{
system("cls");
cout << "**************************************************** " << endl;
cout << "6. Buster's Sirloin and Carrots - $10.00" << endl;
cout << "7. Puppy Sirloin Carrots - $8.50 " << endl;
cout << "8. Buster's Chicken Kibble - $10.00 " << endl;
cout << "9. Puppy Chicken Kibble - $8.50 " << endl;
cout << "**************************************************** " << endl;
cout << "Please select a number from the menu above. " << endl;
cin >> selection;
}
while (selection > 1 && selection < 5);
{
cout << "How many of these would you like? (each back weighs 61lbs) " << endl;
cin >> howMany2;
}
if (selection < 1 || selection > 5);
{
cout << "Please select 1 through 5 only. " << endl;
}

switch (selection)
{
case 6:
{
dryFoodDesc = "Buster's Sirloin and Carrots ";
dryFoodPrice = 10.00;
break;
}
case 7:
{
dryFoodDesc = "Puppy Sirloin and Carrots ";
dryFoodPrice = 8.50;
break;
}
case 8:
{
dryFoodDesc = "Buster's Chicken Kibble ";
dryFoodPrice = 8.50;
break;
}
case 9:
{
dryFoodDesc = "Puppy Chicken Kibble ";
dryFoodPrice = 8.50;
break;
}
default:
{
cout << "You did mot enter a valid selection. " << endl;
selection = 0;
}
}
}

void displayResults (int howMany, string biscuitDesc, double biscuitPrice, int howMany2, string dryFoodDesc, double dryFoodPrice, double &finalTotal)
{
cout << "Thank you for shopping with us! " << endl;
cout << "********************************************************** " << endl;
cout << "You ordered " << howMany << " boxes of " << biscuitDesc<< " at $" << biscuitPrice << " each and " << howMany2 << " bags of " << dryFoodDesc << " at $" << dryFoodPrice << " each." << endl;
finalTotal = ((howMany * biscuitPrice) + (howMany2 * dryFoodPrice)) * TAX;
cout << "Your total is $" << finalTotal << endl;
cout << "Have a nice day! " << endl;
}
Last edited on
Topic archived. No new replies allowed.