F&W Sdn Bhd is a packaging company. Write a program in C++ to help the company determines how many boxes that are needed for an item. For example, a box of shampoo can have 30 bottles in it. So, 95 bottles of shampoo need to be packed into 3 boxes and 5 are left. The number of each item and the number of an item that can be packed in a box are received as inputs. Display the number of boxes needed and the number of leftover items.
#include <iostream>
using namespace std;
int main()
{
int number_item, one_box, sum2 = 0;
cout << "The number of each item: ";
cin >> number_item;
cout << "\nthe number of an item that can be packed in a box: ";
cin >> one_box;
cout << "\n######################################\n";
cout << "# The number of boxes needed: ";
cout << number_item / one_box << "\t #\n";
cout << "# The number of leftover items: ";
cout << number_item % one_box << "\t #\n";
cout << "######################################\n";
return 0;
}
Comments
Leave a comment