I'm trying to make a calculator, that calculates the amount of pancakes you can make. You input the amount of eggs, milk and flour you have and it should output the amount of pancakes you can make, based on the values you input dived by the minimum amounts you need.
To do that I have to find the smallest value you input, i tried using the min() function, but the code fails to compile. I tried following some tutorials, but it just doesn't work and I don't know what am I doing wrong. I also can't really make out anything out of the error message the compiler throws at me. (I use cpp.sh to compile my code).
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
int eggAmount;
int eggMinimum = 1;
int milkAmount;
int milkMinimum = 200; // ml
int flourAmount;
int flourMinimum = 100; // g
cout << "C++ BLIN CALC v0.1 - Ported by @xzotikk\n";
cout << "C++ BLIN CALC IS STARTING UP...\n";
cout << "How many eggs do you have?\n";
cin >> eggAmount;
cout << "How much milk do you have?\n";
cin >> milkAmount;
cout << "How much flour do you have?\n";
cin >> flourAmount;
bool killSwitch;
if (eggAmount < eggMinimum) {
cout << "You need at least one egg!\n";
killSwitch = true;
} else {
killSwitch = false;
}
if (milkAmount < milkMinimum) {
cout << "You need at least 200ml of milk!\n";
killSwitch = true;
} else {
killSwitch = false;
}
if (flourAmount < flourMinimum) {
cout << "You need at least 100g of flour!\n";
killSwitch = true;
} else {
killSwitch = false;
}
if (eggAmount < eggMinimum || milkAmount < milkMinimum || flourAmount < flourMinimum) {
cout << "Press A to exit.\n";
} else {
int eggDiv = eggAmount / eggMinimum;
cout << "You have " << eggDiv << " eggs to use.\n";
int milkDiv = milkAmount / milkMinimum;
cout << "You have " << milkDiv << " portions of milk.\n";
int flourDiv = flourAmount / flourMinimum;
cout << "You have " << flourDiv << " portions of flour.\n";
cout << min(eggDiv, milkDiv, flourDiv);
}
char killSwitchButton;
cin >> killSwitchButton;
if (killSwitch == true) {
switch (killSwitchButton) {
case 'a':
cout << "C++ BLIN CALC IS SHUTTING DOWN...";
return 1;
break;
}
}
}
Here is the error message:
In file included from /usr/include/c++/4.9/bits/char_traits.h:39:0,
from /usr/include/c++/4.9/ios:40,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/c++/4.9/iostream:39,
from 1:
/usr/include/c++/4.9/bits/stl_algobase.h: In instantiation of 'const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
63:40: required from here
/usr/include/c++/4.9/bits/stl_algobase.h:243:26: error: '__comp' cannot be used as a function
if (__comp(__b, __a))
^