SHARE
TWEET

task2 (oop lab3) 3rd sem

Adrita Jan 22nd, 2020 (edited) 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. class flight
  4. {
  5. private:
  6.     int Flight_number;
  7.     string Destination;
  8.     float Distance;
  9.     float MaxFuelCapacity;
  10.     void CalFuel()
  11.     {
  12.         if(Distance<=1000)
  13.             MaxFuelCapacity=500;
  14.         else if(Distance>1000&&Distance<=2000)
  15.             MaxFuelCapacity=1100;
  16.         else if(Distance>2000)
  17.             MaxFuelCapacity=2200;
  18.     }
  19. public:
  20.     void FeedInfo(int fn,string des,float dis)
  21.     {
  22.         Flight_number=fn;
  23.         Destination=des;
  24.         Distance=dis;
  25.         CalFuel();
  26.     }
  27.     void ShowInfo()
  28.     {
  29.  
  30.         cout<< "flight number: "<< Flight_number <<endl;
  31.         cout<< "destination: "<< Destination <<endl;
  32.         cout<< "distance: "<< Distance <<endl;
  33.         cout<< "Max fuel capacity: "<< MaxFuelCapacity <<endl;
  34.  
  35.     }
  36. };
  37. int main()
  38. {
  39.     flight f1;
  40.     f1.FeedInfo(10,"USA",2500.0);
  41.     f1.ShowInfo();
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top