There is a problem I am supposed to solve that is normally easy, but it has a catch.
There are 2 types of candy. One type weighs m1
kg and is sold for s1
Euro. A second type weighs m2
kg and is sold for s2
Euro. All numbers are integers.
The question is, which type of candy costs more per kg?
The catch is, you can't use divide operation at all, neither /
nor %
.
For example, if we have the numbers as m1
=2, s1
=17, m2
=3, and s2
=14 then the answer needs to be that the first candies are more expensive as 17/2=8.5 and 14/3=4.(3).
As I am a C++ student, I am restricted to use only that which has been taught so far in the class to determine the more expensive candy. The only thing we learned so far was +
-
/
*
%
and if
statement with else
. Also ==
>
<
&&
||
.