-
Notifications
You must be signed in to change notification settings - Fork 0
/
Class2.cpp
59 lines (59 loc) · 995 Bytes
/
Class2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
using namespace std;
class flight
{
private:
int fight_num;
float destination, distance, fuel;
char s_name[10];
float calFuel()
{
if (distance <= 1000)
{
fuel = 500;
}
else if (distance > 1000 && distance <= 1800)
{
fuel = 900;
}
else if (distance > 1800 && distance <= 2200)
{
fuel = 1100;
}
else
{
fuel = 1300;
}
return fuel;
}
public:
flight()
{
cout << "ENTER FLIGHT NUMBER: ";
cin >> fight_num;
cout << "ENTER NAME: ";
cin >> s_name;
cout << "ENTER DESTINATION: ";
cin >> destination;
cout << "ENTER DISTANCE: ";
cin >> distance;
}
void showdata()
{
cout << "ENTER FLIGHT NUMBER: "<<fight_num<<endl;
cout << "ENTER DESTINATION: "<<destination<<endl;
cout << "ENTER DISTANCE: "<<distance<<endl;
cout << "ENTER NAME: "<<s_name<<endl;
cout << "FUEL REQUIRED: " << calFuel();
}
};
int main()
{
//flight fly;
//fly.showdata();
flight* ptr;
flight fly;
ptr = &fly;
ptr->showdata();
return 0;
}