Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include<iostream>

#include<conio.h>
using namespace std;
class Flight {
private:
int flight_num;
float distance;
float fuel_req;
char shift_name[10];
char dest[10];
float calfuel()
{
if (distance <= 1000) {
return 500.0;
}
else if (distance > 1000 && distance < 1800) {
return 900.0;
}
else if (distance > 1800 && distance < 2200) {
return 1100.0;
}
else {
return 1300.0;
}
}
public:
Flight() {
cout << "enter value of flight_num :";
cin >> flight_num;
cout << "enter value of distance:";
cin >> distance;
cout << "enter shift_name :";
cin.ignore;
cin.getline(shift_name, 10);
cout << "enter destination :";
cin.ignore;
cin.getline(dest, 10);
fuel_req = calfuel();
}
void showdata() {
cout << dest << "\t" << distance << "\t" << flight_num << "\t" <<
shift_name << "\t" << fuel_req << endl;
}
int main() {
Flight Emirates;
Emirates.showdata;
system("pause");
}
};

You might also like