Learn Programming through Logical Thinking Series – 2

Learn Programming through Logical Thinking Series – 2

This blog explains about Learn Programming through Logical Thinking Series – 2 and is given below : 

_______________________________________________________________________________

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:

Aptitude:

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

Answer:

Ratio of time taken by A and B = 12 days and  x days . 

The efficiency of A and B will be in the ratio 100 : 160 =  5 : 8 

  Now, if we calculate the indirect proportion method – it would be

 5 : 8 = 12 : x

8 x = 5 * 12

X = 7.5 days

 So B takes only 7 and half days to complete the entire work . 

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);

}

}

_______________________________________________________________________________________