A simple program that will ask the user to give a number and then the program will generate the asterisk triangle using Java programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

Program Listing

/* Asterisk.java
 * Author : Jake Rodriguez Pomperada, MAED-IT, MIT
 * April 5, 2021   8:13 PM
 * www.jakerpomperada.blogspot.com
 * www.jakerpomperada.com
 * jakerpomperada@gmail.com
 * Bacolod City, Negros Occidental
 */ 

import java.util.Scanner;

public class Asterisks {
	 public static void main(String[] args) {
	        Scanner scan = new Scanner(System.in);
	        
	        System.out.println();
	        System.out.print("\tAsterisk Triangle in Java");
	        System.out.println("\n");
	        System.out.print("\tEnter a number: ");
	        int number = scan.nextInt();
	        int res;
	        System.out.println("\n");
	        for (int a=1; a<=number; a++) {
	        	 System.out.print("\t");
	            res = number - a;
	            for (int b=0; b<=res;b++) {
	                System.out.print("*");
	            }
	            System.out.println("");
	        }
	    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *