CSE1002 Boarding Pass
Generate boarding pass for the passengers of a ship which starts from Chennai to Andaman. The boarding pass must be generated automatically with a pass number that begins with "CA" and followed by a number that is automatically incremented from value 'x', details like passenger name, age, mobile number, address, date of journey and fare. There is a seasonal discount based on the age of the passengers. Write a non member function called discount which calculates the discount in the fare for the passenger with the following discounts. For the age group `between 12 and 58, both inclusive’ there is 20% discount in the fare, for the age group ‘above 58’, there is 40% discount and for the children (age under 12), 50% discount. Write a C++ program to generate pass for 'n' users.
Input Format:
Passenger name
Value of 'x'
Age
Address
date_of_Journey
mobile number
Original Fare
Output Format:
passenger name
Boarding pass number
age
date_of_Journey
mobile number
Total fare after discount based on age
Boundary Conditions:
>=1
C++ CODE:
Enter the name,x,address,age,mobile number,fare
PROCESSING:
if(age<12) { fare-=(fare*0.5); return fare; } If(age>=12 && age<=58) { fare-=(fare*0.2); return fare; } If(age>58){
fare-=(fare*0.4);
return fare;}
OUTPUT:
Display the name,“CA”remaining code(x),age,mobile number,total fare
PSUEDO CODE:-
1)Start
2)Read the name,x,age,adddress,mobile number
3)If(age<12) { fare-=(fare*0.5); return fare; } If(age>=12 && age<=58) { fare-=(fare*0.2); return fare; } If(age>58){
fare-=(fare*0.4);
return fare;}
4)END
Generate boarding pass for the passengers of a ship which starts from Chennai to Andaman. The boarding pass must be generated automatically with a pass number that begins with "CA" and followed by a number that is automatically incremented from value 'x', details like passenger name, age, mobile number, address, date of journey and fare. There is a seasonal discount based on the age of the passengers. Write a non member function called discount which calculates the discount in the fare for the passenger with the following discounts. For the age group `between 12 and 58, both inclusive’ there is 20% discount in the fare, for the age group ‘above 58’, there is 40% discount and for the children (age under 12), 50% discount. Write a C++ program to generate pass for 'n' users.
Input Format:
Passenger name
Value of 'x'
Age
Address
date_of_Journey
mobile number
Original Fare
Output Format:
passenger name
Boarding pass number
age
date_of_Journey
mobile number
Total fare after discount based on age
Boundary Conditions:
>=1
C++ CODE:
#include<iostream>INPUT:
using namespace std;
int i=0,j=0,k=0;
class passenger
{
public:
string name[100],addr[100],doj[100];
long mobile;
int age,x;
float fare;
void get();
void print(float total);
}pass;
float discount(int age, float fare)
{
if(age<12) { fare-=(fare*0.5); return fare; } if(age>=12 && age<=58) { fare-=(fare*0.2); return fare; } if(age>58)
{
fare-=(fare*0.4);
return fare;
}
}
void passenger::get()
{
cin>>name[++i]>>x>>age>>addr[++j]>>doj[++k]>>mobile>>fare;
}
void passenger::print(float total)
{
cout<<name[i]<<endl<<“CA”<<x<<endl<<age<<endl<<doj[k]<<endl<<mobile<<endl<<total;
}
int main()
{
pass.get();
float total;
total=discount(pass.age,pass.fare);
pass.print(total);
return 0;
}
Enter the name,x,address,age,mobile number,fare
PROCESSING:
if(age<12) { fare-=(fare*0.5); return fare; } If(age>=12 && age<=58) { fare-=(fare*0.2); return fare; } If(age>58){
fare-=(fare*0.4);
return fare;}
OUTPUT:
Display the name,“CA”remaining code(x),age,mobile number,total fare
PSUEDO CODE:-
1)Start
2)Read the name,x,age,adddress,mobile number
3)If(age<12) { fare-=(fare*0.5); return fare; } If(age>=12 && age<=58) { fare-=(fare*0.2); return fare; } If(age>58){
fare-=(fare*0.4);
return fare;}
4)END
0 Comments