Find the ratio of Car commutors to Total Commutors

1 view
Skip to first unread message

Rohit Ghatol

unread,
Dec 11, 2007, 7:35:27 AM12/11/07
to Pune Java Interview Questions Group
Problem statement - In a City for a year, we know the number of total
commutors and we also know the number of car commutors. Find out the
ratio (by parts) of car commutors in total commutors

Answer -
public class Commutors{
public static void main(String[] args){
public static final long TOTAL_COMMUTORS = 12 * 60 * 60 * 1000 *
20 * 100;
public static final long CAR_COMMUTORS = 12 * 60 * 60 * 100 * 20
* 1;

System.out.println("The ratio of Car commutors in total commutors
is "+
(TOTAL_COMMUTORS / CAR_COMMUTORS);

}
}

Note - the number of commutors is broken down into a product for your
convienece.

What should this program print?

Yogesh Patel

unread,
Dec 11, 2007, 7:56:41 AM12/11/07
to pune-jav...@googlegroups.com
I think program should be like that:-

public class Commutors{

public static final long TOTAL_COMMUTORS = 12 * 60 * 60 * 1000 *
20 * 100;
    public static final long CAR_COMMUTORS = 12 * 60 * 60 * 100 * 20
* 1;


  public static void main(String[] args){
   System.out.println("The ratio of Car commutors in total commutors
is "+
       (TOTAL_COMMUTORS / CAR_COMMUTORS);

   }
}

And answer should be 1000.

Yogesh//

Rohit Ghatol

unread,
Dec 11, 2007, 10:48:30 AM12/11/07
to pune-jav...@googlegroups.com
The actual answer is 5. Now the question remains WHY?

Could someone try to explain?
--
Project Manager at Synerzip Softech
Also run the Pune Google Technology User Group
http://pune-gtug.blogspot.com
Reply all
Reply to author
Forward
0 new messages