8.8 Assignment 3
SUBMISSION: Electronically via myUnisa
Please note that we automatically give four days extension for this aassignment. It will be
to your own advantage to check after a few days whether the assignment has been registered
on the system. If you have not completed the assignment by the extension date, submit
whatever you have completed – you will get marks for everything that you have done.
If myUnisa is off-line when you want to submit the assignment, you need not contact us, because
we will be aware of it. Simply submit it as soon as myUnisa is available again.
DUE DATE 31 August 2021
UNIQUE NUMBER 841712
EXTENSION No extension
TUTORIAL MATTER Study Guide, Lessons 1 – 30
CONTRIBUTION WEIGHT TO 30%
SEMESTER MARK
QUESTIONS Practical exercises
IS YOUR SOFTWARE INSTALLED?
If you struggle to install the software, please contact your e-tutor.
Introduction
You are required to write a program that simulates a flight booking system.
A sample program execution is provided at the end of the document, to help you visualize and understand what the program
should do. You should use the same input as the sample program, for the screenshots that you submit with your assignment.
The flight route is from Johannesburg to Cape Town with the travel duration fixed at 2 ½ hours.
o Departure and arrival locations remain the same.
o Departure is always from Johannesburg and destination is always Cape Town.
The departure and arrival times are:
Option Departure Time Arrival Time
1 7:00 9:30
2 9:00 11:30
3 11:00 13:30
4 13:00 15:30
5 15:00 17:30
The seating arrangement is six seats in a row, three on the left side and three on the right side of the plane with a walkway
(passage) in between. See the image of the setup below.
41
,Assignment 3:
Program:
//Flight booking system.
#include <iostream>
#include <string>
using namespace std;
const int col_Num = 6;
const char row_A_H = 9;
const int Dep_Arr = 2;
const int NUM_Opt = 5;
const int TAG_WIDTH = 21 , Class_Border = 4;
float FirstFlyTime = 7.00;
struct TicketInfo
{
string name, flight,departure, destination,Class,SeatNO;
float time[Dep_Arr];
int choice_Time, choice_Seat,tracker[NUM_Opt];
};
//________Displaying Fyight Schedule time from Depature to Arrival__
void LoadingScheduleTime(float SceduleP[][Dep_Arr])
{
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 2; j++)
SceduleP[i][j] = FirstFlyTime + 2*i +j*2.30;
}
}
//_______Input__and ___Validation of the Input Number if is an Intiger_________
Put_validateNumberisNotLetter(int & Num)
{
while(!( cin >> Num ) )
{
cout << "Error is not a Number" << endl;
cout << "Enter again: ";
cin.clear();
cin.ignore(100, '\n');
}
return Num;
}
//_______Converting Number to String and Asteris_**____________________________
string CombineLetterAndNumber( int ArraySitLetter, int ArraySitNumber)
{
, char rowOFletters ;
int colOFnumbers ;
string sitNumber = "";
rowOFletters = ArraySitLetter + 65;
colOFnumbers = ArraySitNumber + 49;
sitNumber += rowOFletters ;
sitNumber += colOFnumbers ;
return sitNumber;
}
//_______Validate_if_Number is on the_range_1_5_____
validadeNumberRange(int & One_FiveP)
{
while (One_FiveP <= 0 || One_FiveP > NUM_Opt )
{
cout << "Incorrect option! Please choose from 1-5." << endl;
cout << "Enter again: ";
cin.clear();
cin.ignore(100, '\n');
cin >> One_FiveP;
cin.clear();
cin.ignore(100,'\n');
}
return One_FiveP;
}
// find numerical index of row
int charToNumber(char L)
{
return toupper(L) - 'A'; // 0, 1, 2, 3, or 4 will be returned
}
//______Change the Char_to _Upper_Letter_______
void charToUpperChase(char & c)
{
c = toupper(c);
}
// Display the Character as requested
void displayChars(char c, int i)
{
for (int j = 0; j < i; j++)
cout << c;
}
//______Input_The _Letter_and _Number_for _Seat_Number_and_Validate it_______
void validateLetterAndNumber(char & CHAR, int & INTN)
{
while(!( cin >> CHAR && cin >> INTN) )
{
SUBMISSION: Electronically via myUnisa
Please note that we automatically give four days extension for this aassignment. It will be
to your own advantage to check after a few days whether the assignment has been registered
on the system. If you have not completed the assignment by the extension date, submit
whatever you have completed – you will get marks for everything that you have done.
If myUnisa is off-line when you want to submit the assignment, you need not contact us, because
we will be aware of it. Simply submit it as soon as myUnisa is available again.
DUE DATE 31 August 2021
UNIQUE NUMBER 841712
EXTENSION No extension
TUTORIAL MATTER Study Guide, Lessons 1 – 30
CONTRIBUTION WEIGHT TO 30%
SEMESTER MARK
QUESTIONS Practical exercises
IS YOUR SOFTWARE INSTALLED?
If you struggle to install the software, please contact your e-tutor.
Introduction
You are required to write a program that simulates a flight booking system.
A sample program execution is provided at the end of the document, to help you visualize and understand what the program
should do. You should use the same input as the sample program, for the screenshots that you submit with your assignment.
The flight route is from Johannesburg to Cape Town with the travel duration fixed at 2 ½ hours.
o Departure and arrival locations remain the same.
o Departure is always from Johannesburg and destination is always Cape Town.
The departure and arrival times are:
Option Departure Time Arrival Time
1 7:00 9:30
2 9:00 11:30
3 11:00 13:30
4 13:00 15:30
5 15:00 17:30
The seating arrangement is six seats in a row, three on the left side and three on the right side of the plane with a walkway
(passage) in between. See the image of the setup below.
41
,Assignment 3:
Program:
//Flight booking system.
#include <iostream>
#include <string>
using namespace std;
const int col_Num = 6;
const char row_A_H = 9;
const int Dep_Arr = 2;
const int NUM_Opt = 5;
const int TAG_WIDTH = 21 , Class_Border = 4;
float FirstFlyTime = 7.00;
struct TicketInfo
{
string name, flight,departure, destination,Class,SeatNO;
float time[Dep_Arr];
int choice_Time, choice_Seat,tracker[NUM_Opt];
};
//________Displaying Fyight Schedule time from Depature to Arrival__
void LoadingScheduleTime(float SceduleP[][Dep_Arr])
{
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 2; j++)
SceduleP[i][j] = FirstFlyTime + 2*i +j*2.30;
}
}
//_______Input__and ___Validation of the Input Number if is an Intiger_________
Put_validateNumberisNotLetter(int & Num)
{
while(!( cin >> Num ) )
{
cout << "Error is not a Number" << endl;
cout << "Enter again: ";
cin.clear();
cin.ignore(100, '\n');
}
return Num;
}
//_______Converting Number to String and Asteris_**____________________________
string CombineLetterAndNumber( int ArraySitLetter, int ArraySitNumber)
{
, char rowOFletters ;
int colOFnumbers ;
string sitNumber = "";
rowOFletters = ArraySitLetter + 65;
colOFnumbers = ArraySitNumber + 49;
sitNumber += rowOFletters ;
sitNumber += colOFnumbers ;
return sitNumber;
}
//_______Validate_if_Number is on the_range_1_5_____
validadeNumberRange(int & One_FiveP)
{
while (One_FiveP <= 0 || One_FiveP > NUM_Opt )
{
cout << "Incorrect option! Please choose from 1-5." << endl;
cout << "Enter again: ";
cin.clear();
cin.ignore(100, '\n');
cin >> One_FiveP;
cin.clear();
cin.ignore(100,'\n');
}
return One_FiveP;
}
// find numerical index of row
int charToNumber(char L)
{
return toupper(L) - 'A'; // 0, 1, 2, 3, or 4 will be returned
}
//______Change the Char_to _Upper_Letter_______
void charToUpperChase(char & c)
{
c = toupper(c);
}
// Display the Character as requested
void displayChars(char c, int i)
{
for (int j = 0; j < i; j++)
cout << c;
}
//______Input_The _Letter_and _Number_for _Seat_Number_and_Validate it_______
void validateLetterAndNumber(char & CHAR, int & INTN)
{
while(!( cin >> CHAR && cin >> INTN) )
{