Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- float CheckOut(int RoomNumber, int age, char Newspaper, char BoardType, int NumberAdults, int NumberChildren, int NumOfDays, char BookingID, char Name);
- int main() {
- int RoomNumber=1 , age=70, NumberChildren=1, NumberAdults=3, FB=20, HB=15, BB=5, NumOfDays=2;
- char BoardType='f', Newspaper='n';
- float CostOfRooms=0;
- char BookingID[20] = "Alvarez8", Name[25] = "Rio Alvarez";
- CheckOut(RoomNumber, age, Newspaper, BoardType, NumberAdults, NumberChildren, NumOfDays, BookingID, Name);
- // printf("The total cost of your stay = %f", CostOfRooms);
- return 0; }
- float CheckOut(int RoomNumber, int age, char Newspaper, char BoardType, int NumberAdults, int NumberChildren, int NumOfDays, char BookingID, char Name){
- float CostOfRooms=0, TotalCost=0, NewsCost=0;
- int CostOfBoard=0, CostOfBoard2=0;
- if (RoomNumber == 1) {
- CostOfRooms = CostOfRooms + 100;
- } else if (RoomNumber == 2) {
- CostOfRooms = CostOfRooms + 85;
- } else if (RoomNumber == 3) {
- CostOfRooms = CostOfRooms + 75;
- } else if (RoomNumber == 4) {
- CostOfRooms = CostOfRooms + 50;
- } else {
- printf("Error. You did not select a room.");
- }
- if (BoardType == 'f'){
- CostOfBoard = 20 * NumberAdults;
- } else if (BoardType == 'h'){
- CostOfBoard = 15 * NumberAdults;
- } else if (BoardType == 'b'){
- CostOfBoard = 5 * NumberAdults;
- }
- if (BoardType == 'f'){
- CostOfBoard2 = (20 * NumberChildren) / 2;
- } else if (BoardType == 'h'){
- CostOfBoard2 = (15 * NumberChildren) / 2;
- } else if (BoardType == 'b'){
- CostOfBoard2 = (5 * NumberChildren) / 2;
- }
- if (age>=65){
- CostOfRooms = CostOfRooms - CostOfRooms/10;
- }
- if (Newspaper == 'y'){
- TotalCost = CostOfRooms + 5.50;
- NewsCost = 5.50;
- }
- CostOfRooms = CostOfRooms * NumOfDays;
- TotalCost = TotalCost + CostOfRooms;
- CostOfBoard = CostOfBoard + CostOfBoard2;
- TotalCost = TotalCost + CostOfBoard;
- 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);
- return CostOfBoard;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement