i have an airline ticketing project and i cant figure it out, i need to take the name and age of passengers and depending on their ages they will get a discount (2% for 13 below and vat exemption + 20% discount for 60 above) and also the prices changes for the group
my friends told me to put the ages in an array but i dont know how to do it properly and my compiler doesnt seem to be calculating it at all and i think its because of me not knowing how to use arrays properly
here is my code
#include <iostream>
#include <string>
using namespace std;
int main()
{
string fly,cls,trip,name;
int des,fare,price;
cout << "/////////////////////////////// WELCOME TO MERC AIRLINES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ";
cout << endl;
cout << " " << endl;
cout << "/////////////////////////////// Please note that payment is only in cash basis \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\" << endl;
cout << " " << endl;
cout << "Please indicate if you are in an international flight or local flight" << endl;
cin >> fly;
if (fly == "local")
{
cout << "Please choose your destination <1-4>" << endl;
cout << " DESTINATION\t TO\t Private Class Fare\tBusiness Class Fare\t";
cout << endl;
cout << "1. Manila\t Batanes\t P8,650 per person \t P15,500 per person";
cout << endl;
cout << "2. Manila\t Bacolod\t P4,543 per person \t P9,500 per person";
cout << endl;
cout << "3. Manila\t Palawan\t P5,882 per person \t P13,200 per person";
cout << endl;
cout << "4. Manila\t Davao \t P4,096 per person \t P4,096 per person";
cout << endl;
}
else if (fly == "international")
{
cout << "Please choose your destination <5-9>" << endl;
cout << " DESTINATION\t TO\t Private Class Fare\tBusiness Class Fare\t";
cout << endl;
cout << "5. Manila\t Malaysia\t P6,199 per person \t P12,150 per person";
cout << endl;
cout << "6. Manila\t Indonesia\t P5,699 per person \t P10,850 per person";
cout << endl;
cout << "7. Manila\t Singapore\t P6,899 per person \t P13,110 per person";
cout << endl;
cout << "8. Manila\t South Korea \t P12,500 per person \t P23,850 per person";
cout << endl;
cout << "9. Manila\t Japan \t P24,800 per person \t P31,450 per person";
}
int localp[4]={8650,4543,5882,4096}; // local fare prices
int localb[4]={15500,9500,13200,4096};
cin >> des;
if (des = 1)
{
cout << "\t DESTINATION: BATANES \n" << endl;
cout << "" << endl;
cout << "\t FARE: PRIVATE P8,650 per person \t BUSSINESS P15,500 per person" << endl;
cout << "\t [P] OR [B] \n" << endl;
loop: cin >> cls;
if (cls == "P")
fare =localp[0];
else if(cls == "B")
fare = localb[0];
else
{
cout << "ERROR: PLEASE INPUT A VALID OPTION" << endl;
goto loop;
}
price = fare * 1.12; // 12% vat
int num1;
cout<<"Enter Number of Reservation: ";
cin>>num1;
char name [num1][10];
if(num1>10 ){
cout<<"\t Exceed the number of passenger reservation, Try again\n";
return 0;
} else {
cout<<"\tNAMES OF PASSENGERS \n";
for(int a = 0; a<num1; a++)
{
cout<<"Passenger "<<a+1<<": ";
cin>>name[a];
}
int age[10];
cout<<"\tAGE OF PASSENGERS \n";
for(int b = 0; b<num1; b++)
{
cout<<"Passenger "<<b+1<<": ";
cin>>age[b];
if (age[b] < 14) || fare = price - price * 0.02;
else if (age[b] > 13)
{
fare = price;
}
else if (age[b] < 60)
{
fare = price;
}
else if (age[b] > 59)
{
price = price - (price * 0.12);
fare = price - price * 0.2;
}
}
cout << "\t ONE WAY OR ROUND TRIP \n" << endl;
cout << "\t [O] OR [R]" << endl;
cin >> trip;
if (trip == "R")
fare = fare * 2;
for (int z=0; z < num1; z++){
cout << name[z] << endl;
cout << age[z] << endl;
cout << fare << endl;
}
}
return 0;
}
}
sorry if i suck im still learning as a student