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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
|
// project2.1.cpp : Defines the entry point for the console application.
//
// newproject2.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
using namespace std;
class managerMenu{
public:
managerMenu();
string homeMenu;
};
managerMenu::managerMenu(){
cout<<"Select an option below (1,2,3)"<<endl
<<"1. Add Booking"<<endl
<<"2. Edit Booking"<<endl
<<"3. Remove Booking"<<endl
<<"4. Change Rates"<<endl
<<"Press '0' to return to main menu."<<endl;
};
class userMenu{
public:
userMenu();
string homeMenu;
string add;
string remove;
string edit;
}; //webUser menu class
userMenu::userMenu(){
cout<<"Select an option below (1,2,3)"<<endl
<<"1. Add Booking"<<endl
<<"2. Edit Booking"<<endl
<<"3. Remove Booking"<<endl
<<"Press '0' to return to main menu."<<endl;
};
class addBooking{
public:
addBooking();
string addMenu;
string bookName;
int startDate;
int currentDate;
int lengthStay;
}; //add booking class
\
addBooking::addBooking(){
}; //contructor
class rateChange{
public:
rateChange();
int monthChange;
int weekChange;
int dayChange;
};
rateChange::rateChange(){
};
class rates{
public:
rates();
int displayMonthRates();
int displayWeekRates();
int displayDayRates();
int monthRate;
int weekRate;
int dayRate;
};
rates::rates(){
dayRate=100;
weekRate=525;
monthRate=1575;
};
class newUser{ //new user class
public:
newUser();
string name;
string password;
};
newUser::newUser(){ //new user constrctor
};
int main(){
int add=1;
int edit=2;
int remove=3;
newUser newUserOne;
int opselect;
int userselect;
int accesslevel;
int rateSelect;
int paySelect;
rates showRate;
rateChange rates;
int mainRateSelect;
int returnMenu=0;
addBooking addMenu;
addBooking addBook;
string*bN=&addBook.bookName;
int checkSelect;
string logout=logout;
fstream reservationFile; //creating output stream file to write reservation input
reservationFile.open("reservationLog.txt", fstream::in | fstream::out);
(ios::app);
if(reservationFile.fail()){
cout<<"File reservation unsuccessfully opened."<<endl
<<"Please check to see if file exists."<<endl;
exit(1);
}
fstream rateFile;
rateFile.open("rate.txt");
if(rateFile.fail()){
cout<<"File reservation unsuccessfully opened."<<endl
<<"Please check to see if file exists."<<endl;
exit(1);
}
cout<<"File 'rate.txt' opened for writing"<<endl;
fstream userFile; //create output stream file to write user login input
userFile.open("userinfo.txt.");
(ios::app);
if(userFile.fail()){
cout<<"File userinfo unsuccessfully opened."<<endl
<<"Please check to see if file exists."<<endl;
exit(1);
}
cout<<"\n the file userinfo.txt has been successfully opened for writing."<<endl;
do{
cout<<"Welcome to the Shady Inn Motel Reservation System!"<<endl
<<"Are you a new user?"<<endl
<<"1. Yes"<<endl
<<"2. No"<<endl;
cin>>userselect;
switch(userselect){
case 1:{
cout<<"Welcome new user!:"<<endl;
cout<<"Please enter user name:"<<endl; //enter username
cin>>newUserOne.name;
userFile<<newUserOne.name; //write username to userFile
cout<<endl;
cout<<"Please enter password:"<<endl; //enter password
cin>>newUserOne.password;
userFile<<newUserOne.password; //write password to user file
cout<<"Please go to manager first to input rates."<<endl;
cout<<"Please select access level:"<<endl
<<"1. Manager"<<endl
<<"2. User"<<endl
<<"3. Clerk"<<endl
<<"4. Travel Agent"<<endl;
cin>>accesslevel;
userFile<<accesslevel;
switch(accesslevel){
case 1:{ //manager
do{
cout<<"Select an option below (1,2,3,4,5)"<<endl
<<"1. Add Booking"<<endl
<<"2. Edit Booking"<<endl
<<"3. Remove Booking"<<endl
<<"4. Change Rates"<<endl
<<"5. Check-in/Check-out"<<endl
<<"enter to logout to start over."<<endl;
//cout<<menu.homeMenu<<endl;
cin>>opselect;
switch(opselect){ //switch statement to help with menu selection
case 1:{ //selected add bookin menu
cout<<"If Booked 2 weeks in advanced, 3% off lodging only"<<endl;
cout<<"Please enter book name:"<<endl; //enter book name
cin>>addBook.bookName;
reservationFile<<addBook.bookName; //write book name to reservationFile file
cout<<endl<<"please enter toady's date(yyyymmdd):"<<endl; //enter current date
cin>>addMenu.currentDate;
reservationFile<<addMenu.currentDate; //write current date to reservationfile
cout<<endl<<"please enter start date:(yyyymmdd)"<<endl; //enter start date
cin>>addMenu.startDate;
reservationFile<<addMenu.startDate; //write start date to reservationfile
cout<<"Monthly Rate:"<<rates.monthChange<<endl //display month rate
<<"Weekly Rate:"<<rates.weekChange<<endl //display week rate
<<"Daily Rate:"<<rates.dayChange<<endl; //display day rate
cout<<"Please enter length of stay:"<<endl; //enter length of stay
cin>>addMenu.lengthStay;
reservationFile<<addMenu.lengthStay; //write length of stay to reservation file
cout<<addMenu.lengthStay/30<<"Months"<<endl //use algorithm to find out # of months,weeks, and days
<<addMenu.lengthStay%30/7<<"Weeks"<<endl
<<addMenu.lengthStay%30%7<<"Days"<<endl;
cout<<"Wholesale or Retail?"<<endl
<<"1. Retail"<<endl
<<"2. Wholesale"<<endl;
cin>>mainRateSelect;
switch(mainRateSelect){
case 1:{
cout<<((addMenu.lengthStay/30*rates.monthChange)+(addMenu.lengthStay%30/7*rates.weekChange)+(addMenu.lengthStay%30%7*rates.dayChange))<<endl;
cout<<"How would you like to pay?"<<endl
<<"1. cash(10%off):"<<endl
<<"2. credit card(8% charge):"<<endl;
cin>>paySelect;
switch(paySelect){
case 1:{
cout<<"Your total cost is:"<<endl
<<((addMenu.lengthStay/30*rates.monthChange)+(addMenu.lengthStay%30/7*rates.weekChange)+(addMenu.lengthStay%30%7*rates.dayChange))*.9<<endl;
break;
}
case 2:{cout<<"Your total cost is:"<<endl
<<((addMenu.lengthStay/30*rates.monthChange)+(addMenu.lengthStay%30/7*rates.weekChange)+(addMenu.lengthStay%30%7*rates.dayChange))*1.08<<endl;
break;
}
break;
}break;}
case 2:{
cout<<((addMenu.lengthStay/30*rates.monthChange)+(addMenu.lengthStay%30/7*rates.weekChange)+(addMenu.lengthStay%30%7*rates.dayChange))*.75<<endl;
cout<<"How would you like to pay?"<<endl
<<"1. cash(10%off):"<<endl
<<"2. credit card(8% charge):"<<endl;
cin>>paySelect;
switch(paySelect){
case 1:{
cout<<"Your total cost is:"<<endl
<<((addMenu.lengthStay/30*rates.monthChange)+(addMenu.lengthStay%30/7*rates.weekChange)+(addMenu.lengthStay%30%7*rates.dayChange))*.75*.9<<endl;
break;
};
case 2:{cout<<"Your total cost is:"<<endl
<<((addMenu.lengthStay/30*rates.monthChange)+(addMenu.lengthStay%30/7*rates.weekChange)+(addMenu.lengthStay%30%7*rates.dayChange))*.75*1.08<<endl;
break;
};
}}}
break;
}
cout<<endl<<"Press '0' to return to menu."<<endl;
cin>>returnMenu;
} }
while(cin>>logout);
return 0;
}}}}}
|