AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
3. Our Experts are looking for yours ?.

# corejava-programming: Program to print the number of jumps to cover a distance

 Rohan is a world renowned kangaroo trainer. He´s now living in Australia, and is training kangaroos for his research project on mobile soccer. (We don´t know the connection, too.) Anyway, for the project to be completed he observes kangaroos for a lot of time - because he wants to figure out the hop count for various kangaroos he´s training. Now, he makes a kangaroo stand at the starting point, and lets him jump to the finishing point - given the hop count of that particular kangaroo, figure out the number of jumps he would take between the starting point to the ending point. Both the starting point and the ending points are inclusive. Note: He will jump only to those positions which are multiples of M or hop count. Input specification: The first line contains number of test cases T. Next T lines contains three integers A, B and M separated by single space. A denotes the starting point, B denotes the finishing point - and M, the hop count - the distance covered by that kangaroo in one jump. Output specification: For each test case print the number of jumps the kangaroo had to make in the range [A, B] inclusive. Constraints: 1<=T<=100,000 1<=A<=B<=10,000,000 1<=M<=10,000,000 Sample Input: 3 1 10 2 5 10 3 7 9 5 Sample Output 5 2 0 corejava x 353programming x 169 Posted On : 2018-01-21 16:59:45.0 Divesh 101180 4

 import java.util.Scanner; public class JumpCalculator { public static void main(String[] args) throws Exception{ Scanner input=new Scanner(System.in); int T=input.nextInt(); int A=0; int B=0; int M=0; int Ans[]=new int[T]; if(1<=T && T<=100000){ for(int i=0;i
Int can store big value ? like 10000000
Divesh
101  18  0
Posted On :2018-01-28 17:15:00.0
Yes, of course It can store 10000000 value as int. there should not be any problem. int range in java is -2,147,483,648 to +2,147,483,647.
Garima Gupta
596  1290  28791
Posted On :2018-01-29 23:11:51.0
No..if int use then loss of data
Divesh
101  18  0
Posted On :2018-01-31 17:40:05.0