Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.77 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. //Creates a function called header.
  6.     void header()
  7.         {
  8.                 cout << "Room | Capacity | Enrollment | Empty Seats | Filled/Not Filled" << endl;
  9.         }
  10.  
  11. //Creates a function called EndOfProgram.
  12. int EndOfProgram()
  13. {
  14.     cout << "Try another room? (Y/N): ";
  15.     char end;
  16.     cin >> end;
  17.  
  18. //if statement to restart from main function if Y or y is pressed (if end is equal to Y or y).
  19.     if (end == 'Y' || end == 'y')
  20.         main();
  21.  
  22. //else if statement to quit the program if N or n is pressed (if end is equal to N or n).
  23.     else if (end == 'N' || end == 'n')
  24.         return 0;
  25.  
  26. //else statement to return to EndOfProgram() if something other than Y, y, N, or n is pressed.
  27.     else
  28.             cout << "Invaid input" << endl;
  29.     EndOfProgram();
  30.         }
  31.    
  32. //Main function.
  33.     int main()
  34.         {
  35.  
  36. //Asks for room number, then applies it to integer roomnum.
  37.                 cout << "Room: ";
  38.             int roomnum;
  39.         cin >> roomnum;
  40.  
  41. //Asks for the capacity, then applies it to integer roomcap.
  42.                 cout << "Capacity: ";
  43.             int roomcap;
  44.         cin >> roomcap;
  45.  
  46. //Asks for the enrollment, then applies it to integer roomenr.
  47.                 cout << "Enrollment: ";
  48.             int roomenr;
  49.         cin >> roomenr;
  50.  
  51. //Makes an integer called empty, then makes it equal to the capacity minus the enrollment.
  52.             int empty = roomcap - roomenr;
  53.  
  54. //Calls back to the header function.
  55.     header();
  56.  
  57. //If else statement to display a different result depending on if the room is full or not.     
  58.             if (empty>0)
  59.                 cout << roomnum << "      " << roomcap << "           " << roomenr << "            " << empty << "            Not Filled" << endl;
  60.             else
  61.                 cout << roomnum << "      " << roomcap << "           " << roomenr << "            " << empty << "            Filled" << endl;
  62.     EndOfProgram();
  63.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement