Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

% modular Problem. Can someone help?

Status
Not open for further replies.

joebeach

Programmer
Sep 12, 1999
13
US
I am having so trouble with % modular in one of my excercise. The problem starts with a wholesale company who will only ship case of 12 items, or master case of 144 items. That means if someone ordered one item, he will get one case of 12. <br>
Inputs:<br>
1. Number of items order 200<br>
2. Case Size 12<br>
4. Master Case Size 144<br>
5. Cost per case 1.5<br>
<br>
Outputs:<br>
1. Number of items order 200<br>
2. Case size 12<br>
3. Master case size 144<br>
4. Cost per items $ 1.5<br>
5. Number of case shipped 5<br>
6. Number of master case 1<br>
7. Number of items shipped 204<br>
8. Total cost of shippment 306.00<br>
<br>
Here are some of my problem:#include &lt;iostream.h&gt;<br>
<br>
int main()<br>
<br>
{<br>
int Case, Mcase, num1, num2, items, total;<br>
Case = 12;<br>
Mcase = 12;<br>
<br>
num1 = items%Case;<br>
num2 = items%Mcase;<br>
<br>
if (num1 &gt; 1)<br>
num1 = +1;<br>
else num1 = 0;<br>
<br>
<br>
<br>
<br>
<br>
cout &lt;&lt; " Enter number of items you want to order: " &lt;&lt;endl;<br>
cin &gt;&gt; items;<br>
<br>
Case = (items/Case) + num1 ;<br>
cout &lt;&lt; "number of case ordered " &lt;&lt;Case &lt;&lt;endl;<br>
Mcase = (items/Mcase) + num2;<br>
cout &lt;&lt; "number of master case ordered " &lt;&lt;Mcase &lt;&lt;endl;<br>
<br>
<br>
<br>
}<br>

 
the mod will only return the remained. If you want to calculate thwe whole and the remaineder you need to do this<br><br><br>quotient = num / input<br>remainder = num % input
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top