hi, im new to programming and i desperately need help, help of any sort is welcome. we were given this problem:
You are the developer for taxiflite.com, a company which charters a light aircraft to
Capetown from Johannesburg. Write a program to assign seats on each flight of the
airline's only plane (capacity: 50 seats (10 rows (A-J) of 5 seats each)). The program
should display the following menu of alternatives: Please type 1 for "First class" and
Please type 2 for "Economy". If the person types 1 your program should ask for the
person’s name and assign a seat in the first class section (rows 1-3 (15 seats)). If the
person types 2, the program should ask for the person’s name and assign a seat in
economy section (rows 4-10 (35 seats)). Menu Option 3 displays the seating
allocation. The program should print a boarding pass indicating the person’s name
and seat number and weather it is in the first class or economy section of the plane
along with the price (R10 000 for first class and R5 000 for economy). Isle seats (A-J
seat number 2 and 3 are subject to a 10% discount) Use a 2-Dimensional array to
represent the seating chart of the plane. Initialize all the elements of the array to 0 to
indicate that all seats are empty. As each seat is assigned, set the corresponding
elements of the array to X to indicate that the seat is no longer available. When the
first class section is full, the program should ask the person if it is acceptable to be
placed in the economy section (and vice versa). If yes then make the appropriate
seat assignment. All seats in each section are assigned randomly unless the person
flying stipulates a specific seat. In the display view, show the percentage occupied of
the total flight (seats taken vs seats available) else if no seats are available then print
the message "Next Flight leaves in 3 hours." All flight information must be saved to a
file.
use Function for initialize, menu, checkSeat, printTicket, displaySeating
so far i have come up wit the following code but I'm stuck and unsure of what I'm doing:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
//program assigns seats to passengers in a flight from CTN to JBG
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
const int firstClassPrice = 10000;
const int economyPrice = 5000;
int name, answer;
double price, discount;
function init()
{
const int rows = 9;
const int columns = 5;
int seat[rows][columns];
for (int rows = 0, rows < 9; rows++)
for (int columns = 0; columns < 5; columns++)
char seat[rows][columns] = "X";
}
function menu()
{
cout << "Welcome to taxiflite.com\n";
<< "Please choose one of the following: \n";
<< "1. First class\n";
<< "2. Economy\n";
<< "3. Seating allocation\n";
<< "4. Ticket holder\n";
cin >> choice;
switch (choice)
}
case 1:
while(rows < 2)
{
function init()
cout << "Enter name: ";
cin >> name;
function checkseat()
if ( column[2] || column[3])
{
discount = 10 / 100 * firstClassPrice;
price = firstClassPrice - discount;
}
else
price = firstClassPrice;
}
//check to see if first class is full
if (seat[2][5] == "X" )
cout << "Would you like for us to book a seat for you in economy(y/n): ";
cin >> answer;
if ( answer == "y" )
function init()
else
"Next flight leaves in 3 hours";
case 2:
while ( rows > 2 )
{
function init()
cout << "Enter name: ";
cin >> name;
if ( column [2] || column[3] )
{
discount = 10 / 100 * economyPrice;
price = economyPrice - discount;
}
else
price = economyPrice;
}
case 3:
function printTicket()
case 4:
default:
cout << "You chose incorrectly\n"
}
function checkSeat()
{
function init()
cout << "Do you want a specific seat?(yes/no: "
cin >> answer;
if( answer == yes )
if( seat[rows][columns] = "0" )
{
char seat[rows][columns] = "X";
name[rows][columns] = name;
}
else
{
//im not sure if this is how to choose a seat randomly
function init()
if(0)
random(0,5)
}
}
function printTicket(string name, type; double price; int seat;)
{
cout <<"Name: " << name << endl;
<< "Seat No: " << seat << endl;
<< "Ticket type: " << type << endl;
<< "price: " << price << endl;
}
function displaySeating()
{
}
return 0;
}
|
Some of the stuff is left out because im unsure. :-)
i think my main problem is understanding what is really required