TRIANGLE OF *S AT THE BOTTOM RIGHT!!! 1 Answer(s) 4 years and 8 months ago
Posted in : Java Beginners
View Answers
October 23, 2008 at 10:25 AM
Hi friend,
Code to solve the problem :
import java.io.*;
class Traingle { public static void main(String[] args) throws IOException { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader bufReader = new BufferedReader(isr);
System.out.println("Enter a integer"); int t = Integer.parseInt(bufReader.readLine()); System.out.println("Integer is " + t);
for(int i=1; i<=t; i++){ //t is the length of the triangle.
for(int space =t-1; space>=0; space--){// for a space between * System.out.print(" "); } for(int j=1; j<=i; j++){ System.out.print("*"); } System.out.print("\n"); } } }