1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
void getMenu();
int getChoice(int);
int getPersons(int);
int getDays(int);
void advWeekend( int , int );
//void scubaBahama(string, int, int);
//void skyDive(string, int, int);
//void baronCliff(string, int, int);
//int discount(double);
int main()
{
int choice,
person,
day,
person1,
days1;
getMenu();
getChoice(choice);
person = getPersons(person1);
day = getDays(days1);
// cout<<person<<endl; // i can see latest value received from getDays(days1)
// cout<<day; // i can see latest value received from getDays(days1)
advWeekend(person,day);
//my expectation is to pass value of person and day to advWeekend(person,day)
// and use it to do calculations for rate inside advWeekend(person,day)
system("pause");
return 0;
}
void getMenu()
{
cout<<"The High Adventure Travel Agency \n";
cout<<"1. Devil's Courthouse Adventure Weekend \n";
cout<<"2. Scuba Bahama \n";
cout<<"3. Sky-Dive Colorado \n";
cout<<"4. Barron Cliff Spelunk \n";
cout<<"5. Exit \n";
}
int getChoice(int selection)
{
int choice;
cout<<"Enter valid choice between 1-5 ";
cin>>choice;
while(choice<=0 || choice>5)
{
cout<<"Please enter valid choice between 1-5 \n";
cout<<"Your choice must be between 1-5 \n";
cin>>choice;
}
return(choice);
}
int getPersons(int noPersons)
{
int persons;
cout<<endl;
cout<<"Enter number of persons to participate ";
cin>>persons;
while(persons<=0)
{
cout<<"You cannot enter number of persons as zero(0) \n";
cout<<"Please enter number of persons to participate \n";
cin>>persons;
}
return(persons);
}
int getDays(int noDays)
{
int days;
cout<<endl;
cout<<"Enter number of days ";
cin>>days;
while(days<3 || days>7)
{
cout<<"You cannot select number of days more than a week \n";
cout<<"Maximum available days is 7 days per person \n";
cout<<"Minimum availalbe days is 3 days per persons \n";
cout<<"Enter number of days again ";
cin>>days;
}
return(days);
}
void advWeekend( int noPerson, int noDay)
{
//int persons,
//days;
// i was assigning another int variable persons and days as
// i was expecting noPerson and noDay will transfer parameter value of noPerson
// and noDay to persons and days
// i should have used noPerson and noDay parameters directly to use its value
// instead of assigning different varaialbes this is why i was not getting
// correct value passed to persons and days in previous program.
float multiply; // i am multiplying value of parameters noPerson & noDay
// and display the result
cout<<endl;
cout<<"Welcome to Devil's Courthouse Adventure Weekend \n";
cout<<"Rates: \n";
cout<<"Base Charge:\t\t\t $350.00/perosn \n";
cout<<"Climbing Instruction:\t\t $100.00/person \n";
cout<<"Equipment Rental:\t\t $40/day/person \n";
cout<<"No of Persons " <<noPerson<<endl;
cout<<"No of Days " <<noDay<<endl;
// now i can see value of person
// passed to function advWeekend it displays value of parameter noPerson
// now i can see value of days passed
// to function advWeekend, it displays value of parameter noDay
multiply = noPerson * noDay;
cout<<"Multiplication of value passed through parameter noPerson is "<<noPerson<<endl
<<" and value passed through parameter noDay is "<<noDay<<" is "<<multiply<<endl;
}
|