GitHub Viewer
/*
* ============================================================================
* Program Name : Number Pattern
* File Name : 057-Number-Pattern.java
* Class Name : NumberPattern
*
* Description:
* This program accepts the number of rows from the user and prints
* a Number Pattern using nested for loops.
*
* Objective:
* - Understand user input using the Scanner class.
* - Learn how to use nested for loops.
* - Print a Number Pattern.
*
* Author : Shaik Mahaboob Basha
* Repository : 01-Core-Java
* Folder : 08-Java-Programs
* ============================================================================
*/
import java.util.Scanner;
public class NumberPattern {
// The main() method is the entry point of every Java application.
public static void main(String[] args) {
// Create a Scanner object to read input from the keyboard.
Scanner scanner = new Scanner(System.in);
// Ask the user to enter the number of rows.
System.out.print("Enter the Number of Rows: ");
// Read the number of rows entered by the user.
int rows = scanner.nextInt();
// Check whether the entered number of rows is valid.
if (rows