Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <iostream>
  2. class FlightBooking {
  3. public:
  4. FlightBooking(int id, int capacity, double reserved);
  5. void printStatus();
  6. private:
  7. int id;
  8. int capacity;
  9. double reserved;
  10. };
  11. void FlightBooking::printStatus()
  12. {
  13. // print report here
  14.  
  15. std::cout << id << std::endl;
  16. std::cout << capacity << std::endl;
  17. std::cout << reserved << std::endl;
  18.  
  19. std::cout << "Flight: " << id << " : " << reserved << "/" << capacity << " " << ((reserved/capacity)*100) << "%" << std::endl;
  20.  
  21. //"Flight [id] : [reserved]/[capacity] ([percentage]%)
  22. }
  23. FlightBooking::FlightBooking(int id, int capacity, double reserved)
  24. {
  25. this -> id = id;
  26. this -> capacity = capacity;
  27. this -> reserved = reserved;
  28. }
  29. int main() {
  30. double id;
  31. double reserved;
  32. double capacity;
  33. std::cout << "Provide flight id: ";
  34. std::cin >> id;
  35. std::cout << "Provide flight capacity: ";
  36. std::cin >> capacity;
  37. std::cout << "Provide number of reserved seats: ";
  38. std::cin >> reserved;
  39. FlightBooking booking(id, capacity, reserved);
  40. booking.printStatus();
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement