I need help with an exercise in my C++ book that I cannot figure out, hopefully someone here can and can help me out.
I have managed to get part A with the following codeDaur's Flowers ships flowers in pots around the world, and orders are placed via the Internet.
a) Write a program that asks the user for the number of flower pots to be shipped, and then displays the number of boxes required. A big box can hold four pots, and a small box only one. Have the program calculate the smallest number of boxes required. The program output should look similar to:
Enter the number of flower pots to ship: <their value, e.g. 25>
We will ship:
6 big box(s)
1 small box(s)
b) Modify the program to allow for a very big box that can hold nine pots. The program output should look similar to:
Enter the number of flower pots to ship: <their value, e.g. 25>
We will ship:
2 very big box(s)
1 big box(s)
3 small box(s)
however, I cannot figure out how to incorporate 'very big boxes' into the mix and get a correct output.Code:#include <iostream.h> int main() { int pots, big, small, remainder; cout<<"Enter the number of flower pots to ship: "; cin>>pots; big = 4; remainder = pots%4; small = remainder; cout<<endl; cout<<(pots/big)<<" big box(s)"<<endl; cout<<(small)<<" small box(s)"; return 0; }



LinkBack URL
About LinkBacks


