Write a main()routine that uses the subroutine that you wrote for part (a) to output 10 lines of stars with 1 star in the first line, 2 stars in the second line, and so on, as shown below. ( 6 marks)
*_*_*_*_*_*_*_*_*_*
*_*_*_*_*_*_*_*_*
*_*_*_*_*_*_*_*
*_*_*_*_*_*_*
*_*_*_*_*_*
*_*_*_*_*
*_*_*_*
*_*_*
*_*
*
package pattern;
public class Pattern {
public static void main(String[] args) {
for(int i=10; i>=1; i--){
for(int j=1; j<=i; j++){
System.out.print("*");
}
System.out.println();
for(int j=1; j<i; j++){
System.out.print("-");
}
System.out.println();
}
}
}
Comments
Leave a comment