Presado - Assessment Task 4.1. Iterative Statements

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Technological Institute of the Philippines

Quezon City

College of Computer Studies

Assessment Task 4.1. Writing Java Program Using Iterative Statements

Presado, Rafael D. ITE012-IS12S1 March 3, 2024

Output of the program:


Input/Source code of th program:

import java.util.Scanner;

public class PatternPrinterRaf {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.println("Enter the number of rows to print: ");

int rows = scanner.nextInt();

scanner.close();

for (int i = 1; i <= rows; i++) {

for (int j = 1; j <= i; j++) {

System.out.print(j);

for (int k = rows; k > i; k--) {

System.out.print("*");

System.out.println();

You might also like