| Member with 257 posts. THREAD STARTER | | Join Date: Jan 2001 Location: New Orleans, Louisiana Experience: Advanced | |
I am still getting the same errors. Here is all of my code. Everyhing was working fine up untill I wrote that fuction. Thanks.
//ø¤°`°¤ø,¸ ¸,ø¤°`°¤ø¤°`°¤ø,¸ ¸,ø¤°`°¤ø¤°`°¤ø,¸ ¸,ø¤°`°¤ø¤°`°¤ø,¸ ¸,ø¤°`°¤ø¤°`
//
//
// Barret Kendrick
// CMPS 161
// 10-27-01
// Project 5
//
// This Program will ask the user for the drink he/she would like to have with
// his buffet order. It will then calculate everything and print the receipt
// for the user.
//
//ø¤°`°¤ø,¸ ¸,ø¤°`°¤ø¤°`°¤ø,¸ ¸,ø¤°`°¤ø¤°`°¤ø,¸ ¸,ø¤°`°¤ø¤°`°¤ø,¸ ¸,ø¤°`°¤ø¤°`
#include <iostream.h>
#define coke = 1.20
#define beer = 2.10
#define water = 0.0
#define adult = 5.95
#define senior_citizen = 4.50
#define child = .45
void getAge (int& age);
void getDrink (int age, char& drink);
void get_subTotal (int age, char drink, float& subtotal, float& drink_price);
void main ()
{
int age;
char drink;
float subtotal;
float drink_price;
cout <<"Welcome to this program. I hope that it helps you to make your"
<<"work a little easier and quicker to complete.";
getAge (age);
getDrink (age, drink);
get_subTotal (age, drink, subtotal, drink_price);
}
//=============================start of getAge===============================
//This function will get the users age.
void getAge (int&age)
{
cout <<"\n\n\nHow old are you? ";
cin >>age;
return;
}
//==============================end of getAge================================
//============================start of getDrink==============================
//This function will get the users drink, and make sure he/she is old enough
//if they choose beer
void getDrink (int age, char& drink)
{
cout <<"\nWhat kind of drink would you like?"
<<"\n 'C' for coke"
<<"\n 'B' for beer"
<<"\n 'W' for water\n"
<<endl;
cin >>drink;
while (drink == 'B' || drink == 'b' && age < 21)
{
cout <<"\nYou are not old enough to drink beer."
<<"\nYou have to be at least 21 years old to purchase beer."
<<"\nYou are only " <<age <<" year(s) old."
<<"\nPlease choose something else.\n\n";
cin >>drink;
}
return;
}
//=============================end of getDrink===============================
//===========================start of subTotal===============================
//This function will calculate the subtotal for this customer.
void get_subTotal (int age, char drink, float& subtotal, float& drink_price)
{
float price;
if (age < 12)
{ price = age * child;
}
else
{ if (age >= 12 && age < 62)
{ price = adult;
}
else
{ price = senior_citizen;
}
}
if (drink == 'b' || drink == 'B')
{ drink_price = beer;
subtotal = price + drink_price;
}
else
{ if (drink == 'c' || drink == 'C')
{ drink_price = coke;
subtotal = price + drink_price;
}
else
{ drink_price = water;
subtotal = price;
}
}
return;
}
//============================end of subTotal================================ |