Write a C++ program to handle the single function of inputting data. Create a st
ID: 3572496 • Letter: W
Question
Write a C++ program to handle the single function of inputting data. Create a structure in C++ to support the following items of information:
- Passenger Name
- Ticket Number
- Frequent Flyer Number (valid alphanumeric or N/A)
- Ticket Price
- Flight Number
- Seat Location
- Flight Date
Choose reasonable data types and sizes.
Write the user interface that will allow the user to specify a set of values
and print the values.
Do not worry about validation rules or error handling. Limit yourself to the
requirements of the program.
Explanation / Answer
#include <iostream>
using namespace std;
struct PassengerInfo
{
char passenger_name[50];
int ticket_number;
char frequent_flyer_no[20];
float ticket_price;
char flight_number[30];
char seat_location[10];
char flight_date[20];
};
void viewPassengerInfo(PassengerInfo);
int main()
{
PassengerInfo p;
cout << "Enter Passenger Name: ";
cin.get(p.passenger_name, 50);
cout << "Enter Frequent Flyer Number: ";
cin >> p.frequent_flyer_no;
cout << "Enter TIcket Number: ";
cin >> p.ticket_number;
cout << "Enter Ticket Price: ";
cin >> p.ticket_price;
cout << "Enter Flight NUmber: ";
cin >> p.flight_number;
cout << "Enter Seat Location: ";
cin >> p.seat_location;
cout << "Enter Flight Date: ";
cin >> p.flight_date;
viewPassengerInfo(p);
return 0;
}
void viewPassengerInfo(PassengerInfo p)
{
cout << " Passenger Information. ";
cout << "------------------------ ";
cout << "Passenger Name:" << p.passenger_name ;
cout << " ";
cout <<"Ticket Number: " << p.ticket_number ;
cout << " ";
cout << "Frequent Flyer Number: " << p.frequent_flyer_no;
cout << " ";
cout <<"Ticket Price: " << p.ticket_price;
cout << " ";
cout << "Flight Number: " << p.flight_number;
cout << " ";
cout <<"Seat Location: " << p.seat_location;
cout << " ";
cout << "Flight Date: " << p.flight_date;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.