Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hi im new and need help. This is my first program using functions and need some help. when i run the program and get to the point that asks if i would like to leave a deposit is where the prob is occuring. If i hit yes it runs fine, however if i hit no when it comes time to display the recipt it cuts half of it off and then I get the prompt to end it. Ive been looking at the code 2 long and cant see the prob
Ty in advance
# include <iostream.h>
# include <stdlib.h>
# include <time.h>
# include <iomanip.h>
# include <math.h>
# include <string.h>
# include <ctype.h>
# include <string.h>float get_deposit(); // Prototype for the get_deposit function
// This function will determine whether or not the user wants to
// enter a deposit. If the user enters a deposit, that value is
// returned program.int get_adult(); //Prototype for the get_adult function
//This function will determine how many adults will be attending
//And return the value to the programint get_child(); //Prototype for the get_child function
//This function will determine how many adults will be attending
//And return the value to the programint get_menu(); //Protype for the get_menu function
//This function will display what menu type the user will purchse
//And returns the value to the program
char get_meal_type(); //Protype for the get_meal_type function
//This function will get the meal type the user selestsint get_day(); //Protype for the get_day function
//This function gets the day of the week for the banquetchar get_hall(); //Protype for the get_hall function
//This function gets the hall the user will be usingint get_finish(); //Prototype for the get_finish function
//This function asks the user if they are finished with their order
int get_finish()
{
int iopt;
cout<<endl<<endl;
cout<<"Are you finished placing your order? \n";
cout<<" 1. for No\n";
cout<<" 2. for Yes\n";
cin>>iopt;
system("cls");return iopt;
}char get_hall()
{
char chall;
cout<< "Which banquet hall would you like to reserve: ";
cin>> chall;
chall = toupper(chall);return chall;
}int get_day()
{
int day;
cout<<endl<<endl<<endl;
cout<< "Please enter the number for the day of the week the banquest will take place: \n";//Asks what day of the week the banquet will take place
cout<&";
cout<< " Number | Day |\n";
cout<&";
cout<< "1. Monday |\n";
cout<< "2. Tuesday |\n";
cout<< "3. Wednesday |\n";
cout<< "4. Thursday |\n";
cout<< "5. Friday |\n";
cout<< "6. Saturday |\n";
cout<< "7. Sunday |\n";
cout<&";
cout<< "===>";cin>>day;//Records the day of the week
cout<< "Thank you!";
cout<< endl<<endl<<endl;
system("cls");return day;
}
float get_deposit()
{
char ans;
float amount = 0;cout<< "Do you wish to leave a deposit? (Y for Yes, N for No): \n";
cin>> ans;
ans = toupper(ans);if (ans == 'Y')
{
cout << "How much would you like to pay in advance? ";
cin >> amount;
}else if (ans == 'N')
{
cout<< "Thank you your order is processing ";
cout<<endl;
}return amount;
}int get_adult()
{
int iadul;
cout<< "Please enter the number of adults to be served: ";
cin>> iadul;
cout<< "Thank you !\n";return iadul;
}int get_child()
{
int ichild;
cout<< "Please enter the number of children to be served: ";
cin>> ichild;
cout<< "Thank you !";
cout<<endl;
system("cls");return ichild;
}int get_menu()
{
int imenu;
imenu = 0;
cout<< "We have the following meal choices' for you to choose from.\n\n";//Aks the user what type of meal
cout<&---------------\n";
cout<< "Meal type | Per Adult | Per Child |\n";
cout<&---------------\n";
cout<< "Deluxe | $15.80 | $9.48 |\n";
cout<< "Standard | $11.75 | $7.05 |\n";
cout<&---------------\n\n";
cout<< "To see what is on each menu press 1 \n";
cout<< "To continue with order press 2\n";
cout<<"===>";cin >> imenu;
imenu = toupper(imenu);
cout<<endl;
system("cls");return imenu;
}char get_meal_type()
{
char cmeal;
cout<<endl<<endl;
cout<< "Enter (D for deluxe, S for standard): ";
cin>> cmeal;//Records the type of meal
cmeal = toupper(cmeal);
cout<< "Thank you!";
cout<< endl<<endl;
system("cls");return cmeal;
}void main()
{
srand((unsigned int)time(NULL));cout <<setiosflags (ios :: fixed | ios :: showpoint) << setprecision (2);
int iadul,ichild,imenu,iopt,ipeep,day;
char cmeal,chall;
double dpr,sur,tot1,admeal,chmeal,tax1,total,dis,due;
float famt;iopt = 1;
//Welcome screen
cout<<endl<<endl<<endl<<endl;//creates white space
cout<< " Welcome to Caswell Catering and Convention Service's automated ordering.";//welcome message
cout<< endl<<endl<<endl;//creates white space
cout<<endl; //White space
system("pause"); //Waits for user
system("cls"); //Clears screenwhile (iopt == 1) //Main menu
{cout<<endl<<endl;
iadul = get_adult();cout<<endl<<endl;//whitespace
ichild = get_child();ipeep = iadul + ichild; //calculates the total party size
while (imenu != 2)
{cout<<endl<<endl<<endl;
imenu = get_menu();if (imenu == 1)
{//Beginning of if statementcout<<"DELUXE MENU\n";
cout<<"-----------\n";
cout<< "Soup or Salad\n";
cout<< "Choice of Appetizers\n";
cout<< "Main course: Roast beef or Baked Salmon,choice of potatoe,choice of vegetable\n";
cout<< "Desert: Pie or Cake\n\n\n";
cout<&;
//end of deluxe menucout<< "STANDARD MENU\n";
cout<< "-------------\n";
cout<< "Soup or Salad\n";
cout<< "Main course: Fried Chicken or Ravioli,choice of potatoe,choice of vegetable\n";
cout<< "Desert: Variety of cookies\n\n";
cout<<endl;
system("pause");
system("cls");}//end of if statement
}//end of while loop
while (cmeal != 'D' && cmeal != 'S')//Makes sure user enters correct letter
{
cmeal = get_meal_type();//If user selects deluxe meal
if (cmeal == 'D')
{
tot1 = (15.80 * iadul) + (9.48 * ichild);
admeal = 15.80 * iadul;
chmeal = 9.48 * ichild;
tax1 = (tot1 * 0.18) + tot1;
}//if user selects standard meal
else if (cmeal == 'S')
{
tot1 = (11.75 * iadul) + (7.05 * ichild);
admeal = 11.75 * iadul;
chmeal = 7.05 * ichild;
tax1 = (tot1 * 0.18) + tot1;
}//If user selects wrong type of meal
else
{
cout<<"Invalid selection\n";
}
}// end of cmeal while loopday = get_day();
if (ipeep <= 50)
{
cout<<endl<<endl;
cout<< "The following banquest halls are open on "<<day<<" to accomodate your party size.\n\n";
cout<< "A - will accomodate 50 people \n";
cout<< "B - will accomodate 100 people \n";
cout<< "C - will accomodate 150 people\n";
cout<< "D - will accomodate 250 people\n";
cout<< "E - will accomodate 350 people\n";
cout<< endl<<endl;
}
else if (ipeep <= 100)
{
cout<<endl<<endl;
cout<< "The following banquest halls are open on "<<day<<" to accomodate your party size.\n\n";
cout<< "B - will accomodate 100 people \n";
cout<< "C - will accomodate 150 people\n";
cout<< "D - will accomodate 250 people\n";
cout<< "E - will accomodate 350 people\n";
cout<< endl<<endl;
}
else if (ipeep <= 150)
{
cout<<endl<<endl;
cout<< "The following banquest halls are open on "<<day<<" to accomodate your party size.\n\n";
cout<< "C - will accomodate 150 people\n";
cout<< "D - will accomodate 250 people\n";
cout<< "E - will accomodate 350 people\n";
cout<< endl<<endl;
}
else if (ipeep <= 250)
{
cout<<endl<<endl;
cout<< "The following banquest halls are open on "<<day<<" to accomodate your party size\n\n";
cout<< "D - will accomodate 250 people\n";
cout<< "E - will accomodate 350 people\n";
cout<< endl<<endl;
}
else if (ipeep <= 350)
{
cout<<endl<<endl;
cout<< "The following banquest halls are open on "<<day<<" to accomodate your party size.\n\n";
cout<< "E - will accomodate 350 people\n";
cout<< endl<<endl;
}
else
{
cout<< "Sorry at this time we can not accomodate a party your size.\n";
cout<< endl<<endl;
}chall = get_hall();
if (chall == 'A')
{
dpr = 55.00;
}
else if (chall == 'B')
{
dpr = 75.00;
}
else if (chall == 'C')
{
dpr = 85.00;
}
else if (chall == 'D')
{
dpr = 100.00;
}
else if (chall == 'E')
{
dpr = 130.00;
}
cout<<endl<<endl;
system("cls");cout<<endl<<endl<<endl;
famt = get_deposit();
cout<<endl<<endl;
iopt = get_finish();total = tot1 + tax1 + dpr;
if (famt <= 99 && famt >= 1)
{
dis = total * 0.01;
}
else if (famt <= 199 && famt >= 100)
{
dis = total * 0.02;
}
else if (famt <= 399 && famt >= 200)
{
dis = total * 0.03;
}
else if (famt <= 799 && famt >= 400)
{
dis = total * 0.04;
}
else if (famt >= 800)
{
dis = total * 0.05;
}}//end of while loop
due = total - famt - dis;
if (day == 1)
{
sur = 0.00;
}
else if (day == 2)
{
sur = 0.00;
}
else if (day == 3)
{
sur = 0.00;
}
else if (day == 4)
{
sur = 0.00;
}
else if (day == 5)
{
sur = 0.07 * due;
due = total - famt - dis + sur;}
else if (day == 6)
{
sur = 0.07 * due;
due = total - famt - dis + sur;
}
else if (day == 7)
{
sur = 0.07 * due;
due = total - famt - dis + sur;
}
if (cmeal == 'D' && iopt == 2)
{
cout<<endl<<endl;
cout<< "Caswell Catering and Convention Center\n";
cout<< " Final Bill \n\n\n";
cout<< " Summary \n\n";cout<< "Number of adults attending: "<<iadul<< "\n";
cout<< "Number of children attending: "<<ichild<<"\n";
cout<< "Cost per adult: 15.80 \n";
cout<< "Cost per child: 9.48 \n";
cout<< "Day of the banquet: "<<day<< "\n";
cout<< "Banquet hall chosen: "<<chall<< "\n";
cout<< "Tip and tax rate: 0.18 \n\n\n";
cout<< " Final Bill \n\n";
cout<< "Total cost of adult meals: "<<admeal<<"\n";
cout<< "Total cost of child meals: "<<chmeal<<"\n";
cout<&
cout<< "Total food cost "<<tot1<< "\n\n";
cout<< "Total cost for tip and tax "<<tax1<< "\n";
cout<< "Banquet hall fee: "<<dpr<< "\n";
cout<< "Surchage: "<<sur<< "\n";
cout<&
cout<< "Total due before Deposit: "<<total<< "\n\n";
cout<< "Deposit given: "<<famt<< "\n";
cout<< "Discount given: "<<dis<< "\n";
cout<&
cout<< "Total Balance Due: "<<due<< "\n\n";
cout<< " Thank you! \n\n\n";}
else if (cmeal == 'S' && iopt == 2)
{
cout<<endl<<endl;
cout<< "Caswell Catering and Convention Center\n";
cout<< " Final Bill \n\n\n";
cout<< " Summary \n\n";cout<< "Number of adults attending: "<<iadul<< "\n";
cout<< "Number of children attending: "<<ichild<<"\n";
cout<< "Cost per adult: 11.75 \n";
cout<< "Cost per child: 7.05 \n";
cout<< "Day of the banquet: "<<day<< "\n";
cout<< "Banquet hall chosen: "<<chall<< "\n";
cout<< "Tip and tax rate: 0.18 \n\n\n";
cout<< " Final Bill \n\n";
cout<< "Total cost of adult meals: "<<admeal<<"\n";
cout<< "Total cost of child meals: "<<chmeal<<"\n";
cout<&
cout<< "Total food cost "<<tot1<< "\n\n";
cout<< "Total cost for tip and tax "<<tax1<< "\n";
cout<< "Banquet hall fee: "<<dpr<< "\n";
cout<< "Surchage: "<<sur<< "\n";
cout<&
cout<< "Total due before Deposit: "<<total<< "\n\n";
cout<< "Deposit given: "<<famt<< "\n";
cout<< "Discount given: "<<dis<< "\n";
cout<&
cout<< "Total Balance Due: "<<due<< "\n\n";
cout<< " Thank you! \n\n\n";}
}

![]() |
VBScript Problem
|
Chat Room
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |