I need to calculate how many containers and boxes there are for an order of cookies. 75 boxes per container, and 24 cookies per box. Both need to have their specified amounts in them so if there're remainders, I need to state how many boxes couldn't fill a container and how many cookies were left over. My code is getting stuck right after I input the total number of cookies ordered.
Input for code is: 2001 Output should be: 83 total boxes, 1 container, 8 remaining boxes, and 9 leftover cookies.
Here's my code:
#include <iomanip>
#include <iostream>
using namespace std;
const int ContBoxes = 75;
const int BoxCookies = 24;
int main() {
int TotCookies;
int TotContainers = 0;
int TotBoxes = 0;
int RemBoxes = 0;
cout << "Input number of cookies ordered: ";
cin >> TotCookies;
if (TotCookies >= 1800) {
TotContainers += 1;
TotCookies -= 1800;
} else if ((TotCookies >= 24) && (TotCookies < 1800)) {
RemBoxes += 1;
TotCookies -= 24;
} else if (TotCookies < 24) {
}
cout << "Your order consists of " << TotContainers << " Containers, "
<< TotBoxes << " Total Boxes, " << RemBoxes
<< " Boxes That couldn't fit in containers, and " << TotCookies
<< " Cookies that couldn't fit in boxes.";
return 0;
}
Aucun commentaire:
Enregistrer un commentaire