Advertisement
Guest User

Crappy pancake calculator

a guest
May 31st, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int flour_owned, eggs_owned, sugar_owned, milk_owned;
  8.     int flour_needed = 40;
  9.     int eggs_needed = 1;
  10.     int sugar_needed = 17;
  11.     int milk_needed = 54;
  12.  
  13.     cout << "How many eggs do you have? ";
  14.     cin >> eggs_owned;
  15.     cout << "How many grams of flour do you have? ";
  16.     cin >> flour_owned;
  17.     cout << "How many grams of sugar do you have? ";
  18.     cin >> sugar_owned;
  19.     cout << "How many millilitres of milk do you have? ";
  20.     cin >> milk_owned;
  21.  
  22.     if(eggs_owned < eggs_needed || flour_owned < flour_needed || sugar_owned < sugar_needed || milk_owned < milk_needed){
  23.         cout << "you cannot make a batch of pancakes :(" << endl;
  24.         return 0;
  25.     }
  26.  
  27.     int flour_owned /= flour_needed;
  28.     int sugar_owned /= sugar_needed;
  29.     int milk_owned /= milk_needed;
  30.     int eggs_owned /= eggs_needed;
  31.     int pancakes;
  32.  
  33.     if (flour_owned<=sugar_owned && flour_owned<=milk_owned && flour_owned<=eggs_owned){
  34.         pancakes=flour_owned;
  35.     } else if (sugar_owned<=milk_owned && sugar_owned<=eggs_owned){
  36.         pancakes=sugar_owned;
  37.     } else if (milk_owned<=eggs_owned){
  38.         pancakes=milk_owned;
  39.     } else{
  40.         pancakes=eggs_owned;
  41.     }
  42.  
  43.     cout << "You can make " << pancakes << " batche(s) of pancakes." << endl;
  44.     cout << "Use " << eggs_needed * pancakes << " egg(s) " << flour_needed * pancakes << " grams of flour " << sugar_needed * pancakes << " grams of sugar and " << milk_needed * pancakes << " millilitres of milk";
  45.  
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement