This is our Learn Programming through Logical Thinking Series – 2.  Here we are going to discuss about one more puzzle or aptitude.  The question looks as follows:

A can do a certain job in 12 years. B is 60% more efficient than A. How many days does B alone take to do the same job?

Ratio of times taken by A and B =160:100   8:5.  Now, if we calculate the direct proportion method – it would be

8:5::12:x

8x = 5*12

X=7.5 days

Algorithm:

1.Get A’s total work in days from user.

2.Then A’s work is multiply by 5.  MultiplyValue= A’s work*5

3.Calculate B’s working days by MultiplyValue is divided by 8.

4.Print B’s working days.

5.Stop.

Now, shall we try to solve the same problem through Java Program?  It is quite simple.  As this is my first puzzle to solve, I have given my class name here as MyAppti1.

public class MyAppti1 {

public static void main(String[] args) {

doubleMultiplyValue,DividedValue,work=12;

MultiplyValue = work * 5;

DividedValue = MultiplyValue / 8;

System.out.println(“B’s work is”  +DividedValue);

}

}