Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int flour_owned, eggs_owned, sugar_owned, milk_owned;
- int flour_needed = 40;
- int eggs_needed = 1;
- int sugar_needed = 17;
- int milk_needed = 54;
- cout << "How many eggs do you have? ";
- cin >> eggs_owned;
- cout << "How many grams of flour do you have? ";
- cin >> flour_owned;
- cout << "How many grams of sugar do you have? ";
- cin >> sugar_owned;
- cout << "How many millilitres of milk do you have? ";
- cin >> milk_owned;
- if(eggs_owned < eggs_needed || flour_owned < flour_needed || sugar_owned < sugar_needed || milk_owned < milk_needed){
- cout << "you cannot make a batch of pancakes :(" << endl;
- return 0;
- }
- int flour_owned /= flour_needed;
- int sugar_owned /= sugar_needed;
- int milk_owned /= milk_needed;
- int eggs_owned /= eggs_needed;
- int pancakes;
- if (flour_owned<=sugar_owned && flour_owned<=milk_owned && flour_owned<=eggs_owned){
- pancakes=flour_owned;
- } else if (sugar_owned<=milk_owned && sugar_owned<=eggs_owned){
- pancakes=sugar_owned;
- } else if (milk_owned<=eggs_owned){
- pancakes=milk_owned;
- } else{
- pancakes=eggs_owned;
- }
- cout << "You can make " << pancakes << " batche(s) of pancakes." << endl;
- 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";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement