Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- //Creates a function called header.
- void header()
- {
- cout << "Room | Capacity | Enrollment | Empty Seats | Filled/Not Filled" << endl;
- }
- //Creates a function called EndOfProgram.
- int EndOfProgram()
- {
- cout << "Try another room? (Y/N): ";
- char end;
- cin >> end;
- //if statement to restart from main function if Y or y is pressed (if end is equal to Y or y).
- if (end == 'Y' || end == 'y')
- main();
- //else if statement to quit the program if N or n is pressed (if end is equal to N or n).
- else if (end == 'N' || end == 'n')
- return 0;
- //else statement to return to EndOfProgram() if something other than Y, y, N, or n is pressed.
- else
- cout << "Invaid input" << endl;
- EndOfProgram();
- }
- //Main function.
- int main()
- {
- //Asks for room number, then applies it to integer roomnum.
- cout << "Room: ";
- int roomnum;
- cin >> roomnum;
- //Asks for the capacity, then applies it to integer roomcap.
- cout << "Capacity: ";
- int roomcap;
- cin >> roomcap;
- //Asks for the enrollment, then applies it to integer roomenr.
- cout << "Enrollment: ";
- int roomenr;
- cin >> roomenr;
- //Makes an integer called empty, then makes it equal to the capacity minus the enrollment.
- int empty = roomcap - roomenr;
- //Calls back to the header function.
- header();
- //If else statement to display a different result depending on if the room is full or not.
- if (empty>0)
- cout << roomnum << " " << roomcap << " " << roomenr << " " << empty << " Not Filled" << endl;
- else
- cout << roomnum << " " << roomcap << " " << roomenr << " " << empty << " Filled" << endl;
- EndOfProgram();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement