Hello. My first thread here @ daniweb.
Im stuck on some source code.
I am trying to create a small program that allows user to input '1' or '2' for class selection on an airplane. 1 for first 2 for economy. the plane capacity is 10, which is also the [array] size. If First Class is full (1-5) cout << "Can we move you to economy" and vice versa. Im having a tough time implementing an array to carry this out and allows the user to fill the capacity without over booking. Here's what i have so far, its pretty far off because I was stuck awhile ago so I created this ugly alternative, but it does basically what i want it to do ish.
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
#include <iomanip>
using std::setw;
int main()
{
const int capacity = 10;
int plane[capacity] = {0};
int decision;
int firstclass = 5;
int economy = 5;
cout << " Hello and Welcome to UNA (United Nerd Air) " << endl;
cout << " Looks Like You're Looking to Purchase Tickets Today?" << endl;
for (int i = 0; i <= 9; i++)
{
cout << endl << setw(45) << "First Class or Economy?" << endl;
cout << setw(42) << "( 1 ) or ( 2 )" << endl;
cin >> decision;
if (decision == 1)
{
cout << setw(45) << "First Class has been selected" << endl << endl;
cout << setw(20) << --firstclass << setw(15) << " First Class seats remain." << endl;
if (firstclass < 1 && economy >= 1)
cout << setw(45) << "First Class is booked. Economy?" << endl;
}
else
if (decision == 2)
{
cout << setw(45) << "Economy has been selected" << endl << endl;
cout << setw(20) << --economy << setw(15) << " Economy seats remain." << endl;
if (economy < 1 && firstclass >= 1)
cout << setw(45) << "Economy is full. First Class?" << endl;
}
else
cout << "Error.\n1. First Class\n2. Second Class" << endl;
}
return 0;
}
any suggestions? help? greatly appreciated.