Apr 29, 2013 at 5:02pm UTC
My problem is i get some errors, let me further myself.
1st problem is I cannot figure out why the for loop will not work in the function, i attempted to take it out and put it in the main, still not working.
I then probably really screwed everything else up trying to get it to work.
2nd problem is im not sure I did the arrays correctly. I cannot use the MAX_TYPE for example in the functions. I would like you all to take a look at it and see what u think.
Note: the display results is not finished I need to complete that still. Thanks!
//Project: Bartender
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
///////////////////////////////////////
//PROTOTYPES
///////////////////////////////////////
void displayWelcome();
void getUserInfo(string&, int&, int&, int&);
double calculateTotal(double&, int&, int&);
void displayResults(string, string, string, string);
int main()
{
//Variables
string buyerName;
string buyerAge;
int type;
int beerBrand;
int numOrdered;
double total;
//Arrays
const int MAX_BRAND = 7;
const int MAX_TYPE = 3;
string brand[MAX_BRAND] = {"Corona", "Budwiser", "Budlight", "MillerLite", "CoorsLight", "Yuengling",
"Heineken"};
string beerType[MAX_TYPE] = {"Draft", "Cans", "Bottles"};
//call this message to display welcome and menu.
displayWelcome();
//Call this message to display menu and getuser info
getUserInfo(buyerName, buyerAge, type, beerBrand, numOrdered);
for (int i=0; i<MAX_TYPE; i++)
{
if(beerType[i] == type)
{
type = beerType[i];
}
}
for (int i=0; i<MAX_BRAND; i++)
{
if(brand[i] == beerBrand)
{
beerBrand = brand[i];
}
}
//call this message to calculate the total cost.
calculateTotal(numOrdered, total, type);
//Call this message to display results
displayResults(buyerName, buyerAge, beerType[i], brand[i] );
return 0;
}
void displayWelcome()
{
cout << "----------------------------------------------" << endl;
cout << "Welcome to the bartender calucation program. " << endl;
cout << "----------------------------------------------" << endl;
cout << endl;
cout << endl;
}
void getUserInfo(string& tempBuyerName, int& tempBuyerAge, int& tempBeerType, int& tempBeerBrand, int&
tempNumOrdered)
{
cout << "What is the buyers name: ";
cin >> tempBuyerName;
cout << "How old is the buyer: ";
cin >> tempBuyerAge;
while(tempBuyerAge < 21)
{
cout << "!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!" << endl;
cout << "!WARNING--Buyer is not of legal age to purchase or consume Alcohol!" << endl;
cout << "!The program will now terminate! !" << endl;
cout << "!Goodbye! !" << endl;
cout << "!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!" << endl;
cout << endl;
cout << endl;
return 0;
}
cout << endl;
cout << endl;
cout << "----------------------------------------------" << endl;
cout << "The buyer IS of age, please proceed. " << endl;
cout << "----------------------------------------------" << endl;
cout << "**********************************************" << endl;
cout << "THE BUYER MAY CHOOSE FROM THE FOLLOWING TYPE: " << endl;
cout << " Draft, Can, or Bottle. " << endl;
cout << "**********************************************" << endl;
cout << endl;
cout << endl;
cout << "**********************************************" << endl;
cout << " THE BRANDS AVAILABLE ARE: " << endl;
cout << " Corona " << endl;
cout << " Budwiser " << endl;
cout << " Bud Light " << endl;
cout << " Miller Lite " << endl;
cout << " Coors Light " << endl;
cout << " Yuengling " << endl;
cout << " Heineken " << endl;
cout << "**********************************************" << endl;
cout << endl;
cout << endl;
cout << "-------------------------------------------------" << endl;
cout << "What type of beer does the buyer wish to purchase: " << endl;
cout << "Press 1 for draft, 2 for cans, and 3 for bottles: ";
cin >> tempBeerType;
cout << "-------------------------------------------------" << endl;
cout << endl;
cout << endl;
cout << "-------------------------------------------------" << endl;
cout << "What brand of beer does the buyer wish to purchase: " << endl;
cout << "Press 1 for Corona, 2 for Budwiser, 3 for Bud Light, 4 for Miller Lite, 5 for Coors Lite, 6"
" for Yuengling, and 7 for Heineken: " << endl;
cin >> tempBeerBrand;
cout << "-------------------------------------------------" << endl;
cout << endl;
cout << endl;
cout << "-------------------------------------------------" << endl;
cout << "How many does the buyer wish to purchase: ";
cin >> tempNumOrdered;
cout << "-------------------------------------------------" << endl;
}
double calculateTotal(int& tempNumOrdered, double& tempTotal, int tempBeerType )
{
if (tempBeerType == 1)
{
return tempTotal = (1.50 * tempNumOrdered);
}
if (tempBeerType == 2)
{
return tempTotal = (2.00 * tempNumOrdered);
}
if (tempBeerType == 3)
{
return tempTotal = (2.75 * tempNumOrdered);
}
}
void displayResults (string tempBuyerName, string tempBuyerAge, string tempBeerType, string tempBeerBrand)
Last edited on Apr 29, 2013 at 5:04pm UTC