Hey I' m trying to create a pattern that's suppose to output multiples of 5 in a pattern like this:
5 10 15 20 25
30 40 45 50
55 60 65
70 75
80
but my output is like this
5 10 15 20 25
30 35 40 45
50 55 60
65 70
75
but when i put asterisks in the print :
*****
****
***
**
*
here's my code:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
int n = 5;
int x =5;
for(int i = n; i>=1; i--){
for(int j = n-1; j>=i; j--){
System.out.print(" ");
}
for(int k = 1; k<=i; k++){
System.out.print(x+" ");
x+=5;
}
System.out.println();
}
}
}
Can somebody help me?I ve been trying to solve this for the past 3 hours. Any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire