Write a java program to display a given range of integer numbers (0 to 9) in the following order:
Example : given (5 to 9), the program displays
56789
67895
78956
89567
95678
The first line displays the min to max range. Each line that follows should display the next higher number except when it hits the maximum number. In that situation, the line wraps back to the minimum sequence. For this problem write a static method to do the printing (for example: printLine ( int min, int max)) and call the method from your main ( ..) which should have only one line of code to display the results. ( minus 4 points for not using static method)
`Hey,
Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
public class Test{
public static void printLine(int min,int max)
{
int[] arr=new int[max-min+1];
for(int i=min;i<=max;i++)
{
arr[i-min]=i;
}
for(int i=0;i<max-min+1;i++)
{
int j=i;
int ct=0;
while(ct<max-min+1)
{
System.out.print(arr[j%(max-min+1)]);
j++;
ct++;
}
System.out.println("");
}
}
public static void main(String []args){
printLine(5,9);
}
}
Kindly revert for any queries
Thanks.
Get Answers For Free
Most questions answered within 1 hours.