Advertisement
Guest User

CheckOut

a guest
Nov 17th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5.  
  6. float CheckOut(int RoomNumber, int age, char Newspaper, char BoardType, int NumberAdults, int NumberChildren, int NumOfDays, char BookingID, char Name);
  7.  
  8.  
  9. int main() {
  10.  
  11.     int RoomNumber=1 , age=70, NumberChildren=1, NumberAdults=3, FB=20, HB=15, BB=5, NumOfDays=2;
  12.     char BoardType='f', Newspaper='n';
  13.     float CostOfRooms=0;
  14.     char BookingID[20] = "Alvarez8", Name[25] = "Rio Alvarez";
  15.  
  16.  
  17.  
  18. CheckOut(RoomNumber, age, Newspaper, BoardType, NumberAdults, NumberChildren, NumOfDays, BookingID, Name);
  19.  
  20.  
  21. //  printf("The total cost of your stay = %f", CostOfRooms);
  22.  
  23.     return 0; }
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. float CheckOut(int RoomNumber, int age, char Newspaper, char BoardType, int NumberAdults, int NumberChildren, int NumOfDays, char BookingID, char Name){
  32.     float CostOfRooms=0, TotalCost=0, NewsCost=0;
  33.     int CostOfBoard=0, CostOfBoard2=0;
  34.  
  35.  
  36.     if (RoomNumber == 1) {
  37.         CostOfRooms = CostOfRooms + 100;
  38.     } else if (RoomNumber == 2) {
  39.         CostOfRooms = CostOfRooms + 85;
  40.     } else if (RoomNumber == 3) {
  41.         CostOfRooms = CostOfRooms + 75;
  42.     } else if (RoomNumber == 4) {
  43.         CostOfRooms = CostOfRooms + 50;
  44.     } else {
  45.         printf("Error. You did not select a room.");
  46.     }
  47.  
  48.     if (BoardType == 'f'){
  49.         CostOfBoard = 20 * NumberAdults;
  50.     } else if (BoardType == 'h'){
  51.         CostOfBoard = 15 * NumberAdults;
  52.     } else if (BoardType == 'b'){
  53.         CostOfBoard = 5 * NumberAdults;
  54.     }
  55.     if (BoardType == 'f'){
  56.         CostOfBoard2 = (20 * NumberChildren) / 2;
  57.     } else if (BoardType == 'h'){
  58.         CostOfBoard2 = (15 * NumberChildren) / 2;
  59.     } else if (BoardType == 'b'){
  60.         CostOfBoard2 = (5 * NumberChildren) / 2;
  61.     }
  62.     if (age>=65){
  63.         CostOfRooms = CostOfRooms - CostOfRooms/10;
  64.     }
  65.     if (Newspaper == 'y'){
  66.         TotalCost = CostOfRooms + 5.50;
  67.         NewsCost = 5.50;
  68.     }
  69.     CostOfRooms = CostOfRooms * NumOfDays;
  70.     TotalCost = TotalCost + CostOfRooms;
  71.     CostOfBoard = CostOfBoard + CostOfBoard2;
  72.     TotalCost = TotalCost + CostOfBoard;
  73.  
  74.         printf("%c  (%c):\nI hope you've enjoyed your stay. Here is your final bill:\nThe total cost of your room came to: %f\nThe total cost of all the party's board came to: %d\nYour daily newspaper bill came to: %f\nFinally, the total cost of your stay amounts to: %f\n", Name, BookingID,  CostOfRooms , CostOfBoard , NewsCost, TotalCost);
  75.  
  76.  
  77.  
  78.  
  79.     return CostOfBoard;
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement