fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int type_class;
  6. double weight, cost;
  7. cin >> type_class >> weight;
  8.  
  9. // Class: Economy 0; Business 2; VIP 3
  10.  
  11. switch (type_class) {
  12. case 1:
  13. if (weight <= 25) {
  14. cout << "0";
  15. } else if (weight > 40) {
  16. cost = 2.00 * (weight - 40);
  17. cout << cost;
  18. } else {
  19. cost = 1.50 * (weight - 25);
  20. cout << cost;
  21. }
  22. break;
  23. case 2:
  24. if (weight <= 35) {
  25. cout << "0";
  26. } else if (weight > 50) {
  27. cost = 1.50 * (weight - 50);
  28. cout << cost;
  29. } else {
  30. cost = 1.25 * (weight - 35);
  31. cout << cost;
  32. }
  33. break;
  34. case 3:
  35. if (weight <= 60) {
  36. cout << "0";
  37. } else {
  38. cout << "30";
  39. }
  40. break;
  41. default:
  42. cout << "Wrong Input" << endl;
  43. break;
  44. }
  45.  
  46. return 0;
  47. }
  48.  
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
Wrong Input