0
UNABLE TO UNDERSTAND THE LOGIC OF THIS PATTERN HENCE FAILED TO WRITE THE CORRECT CODE OF THIS PROGRAM
The pattern is this 12345 34567 56789 78901 90123 Guys, Pls help me out to write the source code in java bluej
3 Answers
+ 1
What code have you written so far ?
+ 1
JusCodin'Bro
FIRST, PLEASE BUY A NEW KEYBOARD! YOUR CAPS LOCK KEY SEEMS TO BE BROKEN!
Next, there are many ways to do things like you want here.
I will give you a hint for one of them. But if you don't FULLY understand, what's going on here, you should not use this as your own solution. Look at this and make your own one!
int start = 1;
for (int line=1;line<=5;line++){
for (int i=start;i<start+5;i++){
System.out.print(i%10);
}
System.out.println();
start = (start + 2) % 10;
}
- 2
int count=0;
for(int i=1;i<10;i++){
System.out.print(i);
count++;
if(count==5){
count=0;
System.out.println();
for(int j=2;j>=0;j--){
System.out.print(i-j);
count++;
}
}