Search Java Programs

Showing posts with label construct-a-triangle-with-the-?*?. Show all posts
Showing posts with label construct-a-triangle-with-the-?*?. Show all posts

Tuesday, January 19, 2010

Write a program to construct a triangle with the ?*?

Here is the code of the program:
import java.io.*;

class triangle{
public static void main(String[] args) {
try{
BufferedReader object = new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the number");
int a= Integer.parseInt(object.readLine());
for (int i=1; i<a;i++ ){
for (int j=1; j<=i;j++ ){
System.out.print("*");
}
System.out.println("");
}
}
catch(Exception e){}
}
}
Download the program.

Website Design by Mayuri Multimedia