Advertisement
Spocoman

Coffee Machine

Sep 17th, 2023
746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     string drink, sugar;
  8.     cin >> drink >> sugar;
  9.  
  10.     int drinkCount;
  11.     cin >> drinkCount;
  12.    
  13.     double sum = drinkCount;
  14.  
  15.     if (drink == "Espresso") {
  16.         if (sugar == "Without") {
  17.             sum *= 0.90 * 0.65;
  18.         }
  19.         else if (sugar == "Normal") {
  20.             sum *= 1.00;
  21.         }
  22.         else if (sugar == "Extra") {
  23.             sum *= 1.20;
  24.         }
  25.  
  26.         if (drinkCount > 5) {
  27.             sum *= 0.75;
  28.         }
  29.     }
  30.     else if (drink == "Cappuccino"){
  31.         if (sugar == "Without") {
  32.             sum *= 1.00 * 0.65;
  33.         }
  34.         else if (sugar == "Normal") {
  35.             sum *= 1.20;
  36.         }
  37.         else if (sugar == "Extra") {
  38.             sum *= 1.60;
  39.         }
  40.     }
  41.     else if (drink == "Tea") {
  42.         if (sugar == "Without") {
  43.             sum *= 0.50 * 0.65;
  44.         }
  45.         else if (sugar == "Normal") {
  46.             sum *= 0.60;
  47.         }
  48.         else if (sugar == "Extra") {
  49.             sum *= 0.70;
  50.         }
  51.     }
  52.  
  53.     if (sum > 15) {
  54.         sum *= 0.8;
  55.     }
  56.  
  57.     printf("You bought %i cups of %s for %.2f lv.\n", drinkCount, drink.c_str(), sum);
  58.  
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement