Advertisement
Guest User

Untitled

a guest
Aug 9th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.18 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. #include <fstream>
  5. using namespace std;
  6.  
  7.  
  8. //Constants for hotels
  9. const int AFFORDABLE = 20;
  10. const int DELUXE = 30;
  11. const int LUXURY = 50;
  12. const int SUITE = 90;
  13.  
  14. //We start asking for user information
  15. void userInfo();
  16. void hotelInfo();
  17. int mainMenu();
  18. int totalRoom(double, double, double, double);
  19. int roomServiceCost(double, double, double, double, double);
  20. double affordable();
  21. double deluxe();
  22. double luxury();
  23. double suite();
  24. double affordableRoomCost(double);
  25. double deluxeRoomCost(double);
  26. double luxuryRoomCost(double);
  27. double suitesCost(double);
  28. void displayCost(double, double, double, double, double, double);
  29.  
  30. int main ()
  31. {
  32. //Open file
  33. ofstream outFile;
  34. outFile.open("billingInfo.txt");
  35.  
  36. //Go to userInfo Function to find personal info
  37. userInfo();
  38.  
  39. //Validators, yes or no questions
  40. char extraRoomChoice, validator;
  41.  
  42. //Variables for each of the rooms
  43. double affordableRooms = 0, deluxeRooms = 0, luxuryRooms = 0, suites = 0;
  44.  
  45. //variable for what room they plan on checking out for the menu
  46. int choiceRoom;
  47.  
  48. //Variable to find out total room
  49. double totalRooms;
  50.  
  51. do
  52. {
  53. choiceRoom = mainMenu();
  54.  
  55.  
  56. //Switch Statement for the menu
  57. switch(choiceRoom)
  58. {
  59.  
  60. //When user selects 0 they move on
  61. case 0:
  62.  
  63. break;
  64.  
  65. //If the user selects 1 it goes to affordable rooms so the user can put how many rooms they choose to have
  66. case 1:
  67. affordableRooms = affordable();
  68.  
  69. break;
  70.  
  71. //If the user selects 2 it goes to deluxe rooms
  72. case 2:
  73. deluxeRooms = deluxe();
  74.  
  75. break;
  76.  
  77. //If the user selects 3 it does this
  78. case 3:
  79. luxuryRooms = luxury();
  80.  
  81. break;
  82.  
  83. //If the user selects 4 this is what it does
  84. case 4:
  85. suites = suite();
  86.  
  87. break;
  88.  
  89. //If the user cannot picka number from 0 - 4 it displays an error messaage
  90. default:
  91. system("clear");
  92. cout << "Error please choose a number from 0-4!";
  93.  
  94. }
  95.  
  96. //It continues the menu until the user selects 0
  97. }while(choiceRoom != 0);
  98.  
  99. //Equation for total rooms
  100. totalRooms = totalRoom(affordableRooms, deluxeRooms, luxuryRooms, suites);
  101.  
  102. //Going to ask if they would like to get an extra room so they can get room service half off
  103. if (totalRooms == 4)
  104. {
  105. cout << "Would you like to check out an extra room to get room service half off? (Y/N)";
  106. cin >> extraRoomChoice;
  107.  
  108. //If they put yes they get to decide what room
  109. if (extraRoomChoice == 'y' || extraRoomChoice == 'Y')
  110. {
  111. cout << "We are only going to add one room of your choice, please choose." << endl;
  112. cout << "1. Affordable room" << endl;
  113. cout << "2. Deluxe room" << endl;
  114. cout << "3. Luxury room" << endl;
  115. cout << "4. Suites" << endl;
  116. cin >> choiceRoom;
  117.  
  118. switch(choiceRoom)
  119. {
  120. //choice one is for affordable rooms
  121. case 1:
  122. cout << "Okay One room has been added to affordable rooms" << endl;
  123. affordableRooms += 1;
  124. break;
  125.  
  126. //Choice 2 is for deluxe rooms
  127. case 2:
  128. cout << "Okay one room has been added to deluxe rooms" << endl;
  129. deluxeRooms += 1;
  130. break;
  131.  
  132. //choice 3 is for luxury rooms
  133. case 3:
  134. cout << "Okay one room has been added to luxury rooms" << endl;
  135. luxuryRooms += 1;
  136. break;
  137.  
  138. //choice 4 is for suites
  139. case 4:
  140. cout << "Okay one room has been added to Suites" << endl;
  141. suites += 1;
  142. break;
  143.  
  144. //If they fail to choose a number from 1-4 they lose out on the discount
  145. default:
  146. cout << "Error, No room has been added to your account" << endl;
  147. break;
  148. }
  149. }
  150. }
  151.  
  152. //Its the same as above except only now if they have 9 rooms they have an oppurtunity to get free room service
  153. if (totalRooms == 9)
  154. {
  155. cout << "Would you like to check out an extra room for free room service? (Y/N)";
  156. cin >> extraRoomChoice;
  157.  
  158. if (extraRoomChoice == 'y' || extraRoomChoice == 'Y')
  159. {
  160. cout << "We are only going to add one room of your choice, please choose." << endl;
  161. cout << "1. Affordable room" << endl;
  162. cout << "2. Deluxe room" << endl;
  163. cout << "3. Luxury room" << endl;
  164. cout << "4. Suites" << endl;
  165. cin >> choiceRoom;
  166.  
  167. switch(choiceRoom)
  168. {
  169. case 1:
  170. cout << "Okay One room has been added to affordable rooms" << endl;
  171. affordableRooms += 1;
  172. break;
  173.  
  174. case 2:
  175. cout << "Okay one room has been added to deluxe rooms" << endl;
  176. deluxeRooms += 1;
  177. break;
  178.  
  179. case 3:
  180. cout << "Okay one room has been added to luxury rooms" << endl;
  181. luxuryRooms += 1;
  182. break;
  183.  
  184. case 4:
  185. cout << "Okay one room has been added to Suites" << endl;
  186. suites += 1;
  187. break;
  188.  
  189. default:
  190. cout << "Error no room has been added to your account" << endl;
  191. break;
  192.  
  193. }
  194. }
  195. }
  196.  
  197. system("clear");
  198.  
  199. //total rooms calculation
  200. totalRooms = totalRoom(affordableRooms, deluxeRooms, luxuryRooms, suites);
  201.  
  202. //Validator to check if the information they inputted was correct
  203. cout << "Please validate this information: " << endl << endl;
  204.  
  205. cout << "Affordable rooms: " << affordableRooms << endl;
  206. cout << "Deluxe rooms: " << deluxeRooms << endl;
  207. cout << "Luxury rooms: " << luxuryRooms << endl;
  208. cout << "Suites: " << suites << endl << endl;
  209. cout << "Total Rooms: " << totalRooms << endl;
  210.  
  211. cout << "Is this informtaion correct? (Y/N)" ;
  212. cin >> validator;
  213.  
  214. //If statements for the validator.
  215.  
  216. //If they put a y it moves on
  217. if (validator == 'y' || validator == 'Y')
  218. {
  219. cout << "Okay lets continue!" << endl << endl;
  220.  
  221. }
  222.  
  223. //If they put an n it ask the statement again so they cna fix it
  224. if (validator == 'n' || validator == 'N')
  225. {
  226. //It keeps doing this if they keep selecting no
  227. while (validator == 'n' || validator == 'N')
  228. {
  229. do
  230. {
  231. mainMenu();
  232.  
  233. //Switch statement for the menu and display something according to what the user selects
  234. switch(choiceRoom)
  235. {
  236. case 0:
  237.  
  238. break;
  239.  
  240. case 1:
  241. //opening the affordable function and storing whatever it returns into the affordable rooms
  242. affordableRooms = affordable();
  243.  
  244. break;
  245.  
  246. case 2:
  247.  
  248. //Opening the deluxe function
  249. deluxeRooms = deluxe();
  250.  
  251. break;
  252.  
  253. case 3:
  254. //opening the luxury function
  255. luxuryRooms = luxury();
  256.  
  257. break;
  258.  
  259.  
  260. case 4:
  261. //opening the suite function
  262. suites = suite();
  263.  
  264. break;
  265.  
  266. default:
  267. //if user fails to enter a number from 0-4 they get this error message
  268. cout << "Error please choose a number from 0-4!";
  269.  
  270. }
  271. }while (choiceRoom != 0);
  272.  
  273. //Equation for totalRoom
  274. totalRooms = totalRoom(affordableRooms, deluxeRooms, luxuryRooms, suites);
  275.  
  276. //asking user if they would like to check out an extra room since they are close to getting room service half off
  277. if (totalRooms = 4)
  278. {
  279. cout << "Would you like to check out an extra room to get room service half off? (Y/N)";
  280. cin >> extraRoomChoice;
  281.  
  282. //if they choose yes we had an extra room depending on what they choose
  283. if (extraRoomChoice == 'y' || extraRoomChoice == 'Y')
  284. {
  285. cout << "We are only going to add one room of your choice, please choose." << endl;
  286. cout << "1. Affordable room" << endl;
  287. cout << "2. Deluxe room" << endl;
  288. cout << "3. Luxury room" << endl;
  289. cout << "4. Suites" << endl;
  290. cin >> choiceRoom;
  291.  
  292. switch(choiceRoom)
  293. {
  294. case 1:
  295. //we add an affordable if they choose one
  296. cout << "Okay One room has been added to affordable rooms" << endl;
  297. affordableRooms += 1;
  298. break;
  299.  
  300. case 2:
  301. //we add an deluxe of they choose 2
  302. cout << "Okay one room has been added to deluxe rooms" << endl;
  303. deluxeRooms += 1;
  304. break;
  305.  
  306. case 3:
  307. // we add a luxury if they choose 3
  308. cout << "Okay one room has been added to luxury rooms" << endl;
  309. luxuryRooms += 1;
  310. break;
  311.  
  312. case 4:
  313. // we add a suite if they choose 4
  314. cout << "Okay one room has been added to Suites" << endl;
  315. suites += 1;
  316. break;
  317.  
  318. default:
  319. //if they fail to choose a number from 1-4 they miss the oppurtunity for room service
  320. cout << "Error, No room has been added to your account" << endl;
  321. break;
  322. }
  323. }
  324. }
  325.  
  326. //same as the 4 room one except you get room service for free if you check out 10 rooms
  327. if (totalRooms = 9)
  328. {
  329. cout << "Would you like to check out an extra room for free room service? (Y/N)";
  330. cin >> extraRoomChoice;
  331.  
  332. if (extraRoomChoice == 'y' || extraRoomChoice == 'Y')
  333. {
  334. cout << "We are only going to add one room of your choice, please choose." << endl;
  335. cout << "1. Affordable room" << endl;
  336. cout << "2. Deluxe room" << endl;
  337. cout << "3. Luxury room" << endl;
  338. cout << "4. Suites" << endl;
  339. cin >> choiceRoom;
  340.  
  341. switch(choiceRoom)
  342. {
  343. case 1:
  344. cout << "Okay One room has been added to affordable rooms" << endl;
  345. affordableRooms += 1;
  346. break;
  347.  
  348. case 2:
  349. cout << "Okay one room has been added to deluxe rooms" << endl;
  350. deluxeRooms += 1;
  351. break;
  352.  
  353. case 3:
  354. cout << "Okay one room has been added to luxury rooms" << endl;
  355. luxuryRooms += 1;
  356. break;
  357.  
  358. case 4:
  359. cout << "Okay one room has been added to Suites" << endl;
  360. suites += 1;
  361. break;
  362.  
  363. default:
  364. cout << "Error no room has been added to your account" << endl;
  365. break;
  366.  
  367. }
  368. }
  369. }
  370.  
  371. system("clear");
  372.  
  373. //equation for totalRooms
  374. totalRooms = totalRoom(affordableRooms, deluxeRooms, luxuryRooms, suites);
  375.  
  376. //Validator
  377. cout << "Please validate this information: " << endl << endl;
  378.  
  379. cout << "Affordable rooms: " << affordableRooms << endl;
  380. cout << "Deluxe rooms: " << deluxeRooms << endl;
  381. cout << "Luxury rooms: " << luxuryRooms << endl;
  382. cout << "Suites: " << suites << endl << endl;
  383. cout << "Total Rooms: " << totalRooms << endl;
  384.  
  385. cout << "Is this informtaion correct? (Y/N)" ;
  386. cin >> validator;
  387. }
  388. }
  389.  
  390. //Inputting information to the outfile
  391. outFile << "\t\tUser Hotel informtaion" << endl;
  392. outFile << "-----------------------------------------------" << endl;
  393. outFile << "Affordable rooms: " << affordableRooms << endl;
  394. outFile << "Deluxe rooms: " << deluxeRooms << endl;
  395. outFile << "Luxury rooms: " << luxuryRooms << endl;
  396. outFile << "Suites: " << suites << endl << endl;
  397. outFile << "Total Rooms: " << totalRooms << endl;
  398.  
  399. //Equation for room service
  400. double roomService;
  401.  
  402. roomService = roomServiceCost(totalRooms, affordableRooms, deluxeRooms, luxuryRooms, suites);
  403.  
  404.  
  405. //Inputting information to the outfile
  406. outFile << "\t\tUser Hotel informtaion" << endl;
  407. outFile << "-----------------------------------------------" << endl;
  408. outFile << "Affordable rooms: " << affordableRooms << endl;
  409. outFile << "Deluxe rooms: " << deluxeRooms << endl;
  410. outFile << "Luxury rooms: " << luxuryRooms << endl;
  411. outFile << "Suites: " << suites << endl;
  412. outFile << "Room service cost: $" << roomService << endl;
  413. outFile << endl << "Total Rooms: " << totalRooms << endl;
  414.  
  415. //Closing file
  416. outFile.close();
  417.  
  418. //Variables to find out the total cost of each of the rooms
  419. double affordableCost, deluxeCost, luxuryCost, suiteCost, totalCost;
  420.  
  421. //call the affordableroomcost function to get the affordable cost
  422. affordableCost = affordableRoomCost(affordableRooms);
  423.  
  424.  
  425. //call the deluxeroomcost function to get the deluxe cost
  426. deluxeCost = deluxeRoomCost(deluxeRooms);
  427.  
  428.  
  429. //call the luxuryROomCost function to get the luxury cost
  430. luxuryCost = luxuryRoomCost(luxuryRooms);
  431.  
  432. //call the suitecost function to get the suite cost
  433. suiteCost = suitesCost(suites);
  434.  
  435. //totalCOst equation which you add all the rooms
  436. totalCost = affordableCost + deluxeCost + luxuryCost + suiteCost + roomService;
  437.  
  438. double discount;
  439.  
  440. if (totalRooms >= 10)
  441. {
  442. //discount equation depending on how many rooms they pick out
  443. discount = totalCost / 2;
  444. totalCost -= discount;
  445. }
  446.  
  447. //Total cost calculation if they have more than 5 rooms discount
  448. if(totalRooms >= 5 && totalRooms <= 9)
  449. {
  450. //discount equation depending on how many rooms they pick out
  451. discount = totalCost * .20;
  452. totalCost -= discount;
  453. }
  454.  
  455. //calling the displayCost function
  456. displayCost(totalCost, affordableCost, deluxeCost, luxuryCost, suiteCost, roomService);
  457.  
  458. return 0;
  459. }
  460.  
  461. //the main menu function which displays the main menu
  462. int mainMenu()
  463. {
  464. //varible to see which room they choose
  465. int choiceRoom;
  466.  
  467. //to make it look neat
  468. system("clear");
  469.  
  470. //Menu for the user to select which room they would like to check out
  471. cout << "Which room would you like to check out? Press 0 once you are finished." << endl;
  472.  
  473. cout << "1. Affordable room" << endl;
  474. cout << "2. Deluxe room" << endl;
  475. cout << "3. Luxury room" << endl;
  476. cout << "4. Suites" << endl;
  477. cin >> choiceRoom;
  478.  
  479. return choiceRoom;
  480. }
  481.  
  482. //function to find how many affordable rooms they plan on checking out
  483. double affordable()
  484. {
  485. double affordableRooms = 0;
  486.  
  487. system("clear");
  488.  
  489. cout << "How many affordable rooms would you like to check out? ";
  490. cin >> affordableRooms;
  491.  
  492. while (affordableRooms < 0)
  493. {
  494. system("clear");
  495.  
  496. cout << "Error you cannot insert a number less than 0!" << endl;
  497. cout << "Please try again!" << endl << endl;
  498.  
  499. cout << "How many affordable rooms would you like to check out";
  500. cin >> affordableRooms;
  501. }
  502.  
  503. return affordableRooms;
  504. }
  505.  
  506. //function to find out how many deluxe rooms they plan on checking out
  507. double deluxe()
  508. {
  509. double deluxeRoom = 0;
  510.  
  511. system("clear");
  512.  
  513. cout << "How many deluxe rooms would you like to check out? ";
  514. cin >> deluxeRoom;
  515.  
  516. //Validator so they cant put less than 0 rooms
  517. while (deluxeRoom < 0)
  518. {
  519. system("clear");
  520.  
  521. cout << "Error you cannot insert a number less than 0!" << endl;
  522. cout << "Please try again!" << endl << endl;
  523.  
  524. cout << "How many deluxe rooms would you like to check out? ";
  525. cin >> deluxeRoom;
  526. }
  527.  
  528. return deluxeRoom;
  529. }
  530.  
  531. //function to find out how many luxury rooms they plan on checking out
  532. double luxury()
  533. {
  534.  
  535. double luxuryRooms = 0;
  536.  
  537. system("clear");
  538.  
  539. cout << "How many luxury rooms would you like to check out? ";
  540. cin >> luxuryRooms;
  541.  
  542. //Validator so they cant put less than 0 rooms
  543. while (luxuryRooms < 0)
  544. {
  545. system("clear");
  546.  
  547. cout << "Error you cannot insert a number less than 0!" << endl;
  548. cout << "Please try again!" << endl << endl;
  549.  
  550. cout << "How many luxury rooms would you like to check out? ";
  551. cin >> luxuryRooms;
  552. }
  553.  
  554. return luxuryRooms;
  555. }
  556.  
  557. //function to find out how many suites the user plans on checking out
  558. double suite()
  559. {
  560. double suites = 0;
  561.  
  562. system("clear");
  563.  
  564. cout << "How many suite rooms would you like to check out? ";
  565. cin >> suites;
  566.  
  567. //Validator so they cant put less than 0 rooms
  568. while (suites < 0)
  569. {
  570. system("clear");
  571.  
  572. cout << "Error you cannot insert a number less than 0!" << endl;
  573. cout << "Please try again!" << endl << endl;
  574.  
  575. cout << "How many suite rooms would you like to check out? ";
  576. cin >> suites;
  577. }
  578.  
  579. return suites;
  580. }
  581.  
  582. //function to find out the total rooms
  583. double totalRooms(double affordable, double deluxe, double luxury, double suite)
  584. {
  585. //equation to find out the total rooms
  586. double total = affordable + deluxe + luxury + suite;
  587.  
  588. return total;
  589. }
  590.  
  591. //funtion to find out the affordable room cost
  592. double affordableRoomCost(double affordableRooms)
  593. {
  594. double affordableCost;
  595.  
  596. affordableCost = affordableRooms * AFFORDABLE;
  597.  
  598. return affordableCost;
  599. }
  600.  
  601. //same function as above but for deluxe rooms
  602. double deluxeRoomCost(double deluxeRooms)
  603. {
  604.  
  605. double deluxeCost;
  606.  
  607. deluxeCost = deluxeRooms * DELUXE;
  608.  
  609. return deluxeCost;
  610. }
  611.  
  612. //same function as above but for luxury rooms
  613. double luxuryRoomCost(double luxuryRooms)
  614. {
  615. double luxuryCost;
  616.  
  617. luxuryCost = luxuryRooms * LUXURY;
  618.  
  619. return luxuryCost;
  620. }
  621.  
  622. //same function as above but for suites
  623. double suitesCost (double suites)
  624. {
  625. double suiteCost;
  626.  
  627. suiteCost = suites * SUITE;
  628.  
  629. return suiteCost;
  630. }
  631.  
  632. //this is the final function which will display the cost and ask the user where he plans on paying
  633. void displayCost(double totalCost, double discount, double affordableRoomCost, double deluxeRoomCost, double luxuryRoomCost, double suitesCost,
  634. double roomService)
  635. {
  636. //THese are choices the user makes
  637. char payNowChoice, checkout, validator;
  638.  
  639. //To store the card name and card number
  640. string cardName, cardNumber;
  641.  
  642. //Here it displays the total cost of everything
  643. cout << "\t\tYour total cost" << endl;
  644. cout << "-----------------------------------------" << endl;
  645. cout << "Affordable rooms cost: $" << affordableRoomCost << endl;
  646. cout << "Deluxe room cost: $" << deluxeRoomCost << endl;
  647. cout << "Luxury room cost: $" << luxuryRoomCost << endl;
  648. cout << "Suites cost: $" << suitesCost << endl;
  649. cout << "Room Serivce cost: $" << roomService << endl;
  650. cout << "Discount: $-" << discount << endl;
  651. cout << "Total cost: $" << totalCost << endl << endl;
  652.  
  653. //Asking the user if they would like to go and checkout
  654. cout << "Would you like to continue to checkout? (Y/N)";
  655. cin >> checkout;
  656.  
  657. //If they do wish to check out now it will display that
  658. if (checkout == 'y' || checkout == 'Y')
  659. {
  660.  
  661. cout << "Would you like to pay now?(Y/N)" << endl;
  662. cin >> payNowChoice;
  663.  
  664. if (payNowChoice == 'y' || payNowChoice == 'Y')
  665. {
  666. do
  667. {
  668. cout << "Please enter the name on the card" << endl;
  669. cin >> cardName;
  670. cout << endl << endl;
  671.  
  672. cout << "Please enter the card number" << endl;
  673. cin >> cardNumber;
  674. cout << endl << endl;
  675.  
  676. system("clear");
  677.  
  678. cout << "Please check if the information below is correct (Y/N)" << endl;
  679. cout << "Name on the card: " << cardName << endl;
  680. cout << "Card number: " << cardNumber << endl;
  681. cin >> validator;
  682.  
  683. }while(validator != 'y' || validator != 'Y');
  684. }
  685.  
  686. //IF they choose to pay once they arrive
  687. else
  688. {
  689. cout << "Okay we will charge you once you arrive" << endl;
  690. cout << "When you arrive remeber the account is under your name so we can easily" << endl;
  691. cout << "help you.";
  692. }
  693.  
  694. cout << "Thank you for shopping at Tipton Hotels its been a pleasure serving you!" << endl;
  695. }
  696.  
  697. //if they do not wish to checkout
  698. if (checkout == 'n' || checkout == 'N')
  699. {
  700. cout << "Okay until next time!";
  701. }
  702.  
  703. }
  704.  
  705.  
  706. //the very first function
  707. void userInfo()
  708. {
  709. //Opening output file to have user information saved so we can
  710. //recover his account and or sent him his information to his email
  711. //or send the user the receipt to his email
  712. ofstream outFile;
  713. outFile.open("userInfo.txt");
  714.  
  715. //Variables for user information
  716. string fName, lName, email;
  717.  
  718. int age;
  719.  
  720. //Validator if the user info is correct
  721. char userInfoValidator;
  722.  
  723. //Variable for decision of welcome message
  724. char welcomeContinue;
  725.  
  726. //Welcome message output
  727. system("clear");
  728. cout << "Hello welcome to Tipton Hotels, would you like to check out a room? (Y/N) ";
  729. cin >> welcomeContinue;
  730. cout << endl;
  731.  
  732. //Validator if they wish to check out a room
  733. if (welcomeContinue == 'y' || welcomeContinue == 'Y')
  734. {
  735.  
  736. }
  737.  
  738. else if (welcomeContinue == 'n' || welcomeContinue == 'N')
  739. {
  740. cout << "Okay Goodbye!!!";
  741. return;
  742. }
  743.  
  744. else
  745. {
  746. cout << "Error please try again!" << endl;
  747.  
  748. }
  749.  
  750.  
  751. //Output
  752. cout << "Before we start, please enter your age: ";
  753. cin >> age;
  754. cout << endl;
  755.  
  756. //validator if the user is less than the age of 18 he cant use this program
  757. if (age < 18)
  758. {
  759. cout << "Sorry your to young to check out a room. ";
  760. return;
  761. }
  762.  
  763. //asking for the user first name
  764. cout << "What is your first name? ";
  765. cin >> fName;
  766. cout << endl;
  767.  
  768. //asking for the user last name
  769. cout << "Whatis your last name? ";
  770. cin >> lName;
  771. cout << endl;
  772.  
  773. //asking for the user email address
  774. cout << "Okay, "<< fName << " what is your email address? ";
  775. cin >> email;
  776. cout << endl;
  777.  
  778. system("clear");
  779.  
  780.  
  781. //Asking for user validation
  782. cout << "I am going to need you to validate this information." << endl;
  783.  
  784. cout << "Is this Information below correct? (Y/N)" << endl;
  785.  
  786. cout << "First Name: " << fName << endl;
  787.  
  788. cout << "Last Name: " << lName << endl;
  789.  
  790. cout << "Age: " << age << endl;
  791.  
  792. cout << "Email: " << email << endl;
  793.  
  794. cin >> userInfoValidator;
  795.  
  796.  
  797. //Validator
  798. if (userInfoValidator == 'y' || userInfoValidator == 'Y')
  799. {
  800. //if the information is correct then we save it into an output file
  801. outFile << "First Name: " << fName << endl;
  802. outFile << "Last Name: " << lName << endl;
  803. outFile << "Email: " << email << endl;
  804.  
  805. hotelInfo();
  806. }
  807.  
  808. //if they choose no they have to start the function again
  809. if (userInfoValidator == 'n' || userInfoValidator == 'N')
  810. {
  811. while(userInfoValidator == 'n' || userInfoValidator == 'N')
  812. {
  813. //if it isnt correct we do this again till it is corret
  814. system("clear");
  815.  
  816. cout << "Okay lets start again what is your first name? ";
  817. cin >> fName;
  818. cout << endl;
  819.  
  820. cout << "What is your last name? ";
  821. cin >> lName;
  822. cout << endl;
  823.  
  824. cout << "Okay, "<< fName << " what is your email address? ";
  825. cin >> email;
  826. cout << endl;
  827.  
  828. system("clear");
  829.  
  830. cout << "I am going to need you to validate this information. " << endl;
  831.  
  832. cout << "Is this Information below correct? (Y/N)" << endl;
  833.  
  834. cout << "First Name: " << fName << endl;
  835.  
  836. cout << "Last Name: " << lName << endl;
  837.  
  838. cout << "Email: " << email << endl;
  839.  
  840. cin >> userInfoValidator;
  841.  
  842. }
  843.  
  844. //storing the information into the outfile
  845. outFile << "First Name: " << fName << endl;
  846. outFile << "Last Name: " << lName << endl;
  847. outFile << "Email: " << email << endl;
  848.  
  849. hotelInfo();
  850. }
  851.  
  852. //Closing the output file stream
  853. outFile.close();
  854.  
  855.  
  856.  
  857. }
  858.  
  859. void hotelInfo()
  860. {
  861.  
  862. //Variables
  863. int infoRoom; // variable for the choice the user decides to find info about 1
  864. string cont;
  865.  
  866. system("clear");
  867.  
  868. cout << "Okay lets continue!" << endl << endl;
  869.  
  870. //Making a menu for the user to find out more information about each room
  871. do
  872. {
  873. system("clear");
  874. cout << "Which room would you like to know more information about? Press 0 once your";
  875. cout << " finished: " << endl;
  876. cout << "1. Affordable room" << endl;
  877. cout << "2. Deluxe room" << endl;
  878. cout << "3. Luxury room" << endl;
  879. cout << "4. Suites" << endl;
  880. cin >> infoRoom;
  881.  
  882. switch(infoRoom)
  883. {
  884.  
  885. //Case 0 is to end the menu so the user can move on
  886. case 0:
  887. cout << "Okay lets move on!";
  888. cout << endl << endl;
  889. //Calling the main function
  890. main();
  891.  
  892. break;
  893.  
  894. //case 1 shows information for the affordable room
  895. case 1:
  896.  
  897. system("clear");
  898.  
  899. cout << "\t\t\tThe Affordable Room" << endl;
  900. cout << "------------------------------------------------------------------------------" << endl;
  901. cout << "The affordable room cost a night is: $" << AFFORDABLE << endl;
  902. cout << "And if you are interested in unlimited room service it is $40 dollars per room" << endl;
  903. cout << "and its for your whole stay!" << endl;
  904. cout << "The room contains one twin size bed, a TV, along side free wifi, and your" << endl;
  905. cout << "own restroom" << endl << endl;
  906.  
  907. cout << "Every room contains free wifi, speed depends on what room you check out," << endl;
  908. cout << "Call 956-999-9999, for more information.";
  909. cout << endl << endl << "Also anyone who stays in the Tipton Hotel";
  910. cout << "has a gym inside for them to use," << endl << "and we offer free breakfast" << endl << endl;
  911.  
  912. cout << "Enter any key to continue. ";
  913. cin >> cont;
  914.  
  915.  
  916. break;
  917.  
  918. //case 2 shows information for the deluxe room
  919. case 2:
  920.  
  921. system("clear");
  922.  
  923. cout << "\t\t\tThe Deluxe Room" << endl;
  924. cout << "--------------------------------------------------------------------------------" << endl;
  925. cout << "The Deluxe room cost a night is: $" << DELUXE << endl;
  926. cout << "And if you are interested in unlimited room service it is $35 dollars per room" << endl;
  927. cout << "and its for your whole stay!" << endl;
  928. cout << "The room contains one queen size bed, a flat screen TV, and your own";
  929. cout << " restroom" << endl << endl;
  930.  
  931. cout << "Every room contains free wifi, speed depends on what room you check out," << endl;
  932. cout << "Call 956-999-9999, for more information." << endl << endl;
  933. cout << "Also anyone who stays in the Tipton Hotel";
  934. cout << " has a gym inside for them to use," << endl << " and we offer free breakfast." << endl << endl;
  935.  
  936. cout << "Enter any key to continue. ";
  937. cin >> cont;
  938.  
  939. break;
  940.  
  941.  
  942. //case 3 shows information for the Luxury room
  943. case 3:
  944.  
  945. system("clear");
  946.  
  947. cout << "\t\tThe Luxury Room" << endl;
  948. cout << "--------------------------------------------------------------------------------" << endl;
  949. cout << " The Luxury room cost a night is: $" << LUXURY << endl;
  950. cout << "And if you are interested in unlimited room service it is $20 dollars per room" << endl;
  951. cout << "and its for your whole stay!" << endl;
  952. cout << "The room contains one King size bed, a 55 inch flat screen TV, and your";
  953. cout << " own" << endl << "restroom" << endl << endl;
  954.  
  955. cout << "Every room contains free wifi, speed depends on what room you check out," << endl;
  956. cout << "Call 956-999-9999, for more information." << endl << endl;
  957. cout << "Also anyone who stays in the Tipton Hotel";
  958. cout << " has a gym inside for them to use," << endl << " and we offer free breakfast." << endl << endl;
  959.  
  960. cout << "Enter any key to continue. ";
  961. cin >> cont;
  962.  
  963. break;
  964.  
  965. //Case 4 shows information for the suites
  966. case 4:
  967.  
  968. system("clear");
  969.  
  970. cout << "\t\tThe Suite Room" << endl;
  971. cout << "---------------------------------------------------------------------------------" << endl;
  972. cout << "The Suite room cost a night is: $" << LUXURY << endl;
  973. cout << "Room service is completly free and is only available to the Suites";
  974. cout << " and its for" << endl << "your whole stay" << endl;
  975. cout << "The room contains two King size bed, three 60 inch flat screen TV for";
  976. cout << " each room" << endl << "that can display 4K, and two restroom for each room";
  977. cout << endl << endl;
  978.  
  979. cout << "Every room contains free wifi, speed depends on what room you check out," << endl;
  980. cout << "Call 956-999-9999, for more information." << endl << endl;
  981. cout << "Also anyone who stays in the Tipton Hotel";
  982. cout << " has a gym inside for them to use," << endl << "and we offer free breakfast." << endl << endl;
  983.  
  984. cout << "Enter any key to continue. ";
  985. cin >> cont;
  986.  
  987. break;
  988.  
  989. //If the user failes to select a number from 0-4 it display an error message and they try again
  990. default:
  991.  
  992. cout << "Error! not a possible selection!";
  993.  
  994. break;
  995. }
  996.  
  997. }while(infoRoom != 0);
  998.  
  999. main();
  1000. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement