I have this assignment that I can't get it's logic.
An old weighing balance has the following mass blocks:
1kg, 500g, 200g, 100g, 50g, 20g, 10g, 5g, 1g
The program should ask the user to enter the mass (in grams) of a certain object.
P.S: The mass should be an integer number.
Then, it should split this mass into the number of each mass blocks that constitute this mass.
For example:
449g will be split into:
2 blocks of 200g
2 blocks of 20g
1 block of 5g
4 blocks of 1g
Notes:
The masses that are not used should not appear in the output, for example we should not
see in the output a sentence like 0 blocks of 100g.
Whenever many masses of the same value are used, use the plural form blocks instead
of block.
Now assume that each gram costs 0.01$, display the price of the item, knowing that if its mass
is above 1Kg, a discount of 10% has to be done.
I can't use anything more advanced than modulus and if statment. chapter 1 only
Also how can i understand C++ logic ??
Log in to comment