are the codes correct? because im having some errors in getting the output. tnx

create a program that will generate the following display:
use method declaration without return and with argument list. Input
value for the height of triangle.

5
54
543
5432
54321
5432
54
5







import java.io.*;


public class Meth2{
public static BufferedReader x = new BufferedReader(new InputStreamReader(System.in));
void method1() throws IOException{
int num, height;


System.out.pr int("Input height of triangle: ");
height = new Integer(x.readLine()).intValue();


for( int x=1; x<=9; x++ ) {
for( int y=1; y<=x; y++ ) {
System.out.print( "*" );
}
System.out.println( "" );


}
}
}


import java.io.*;


public class MethRun{
public static void main(String args[]) throws IOException{
Meth2 o = new Meth2();
o.method1();
}
}

Recommended Answers

All 4 Replies

pls help me correct my errors :)

Woooow, a BIT of patience may be appropriate.
You must be the most impatient poster I've ever seen, complaining about not getting an answer after less than a minute.

We're not here to proofread your programs. What is the output you're getting, and what were you expecting to get?

Use code tags, I (and many others) won't read any code that's not formated in a way that makes it readable.

One for loop counting up, one for loop counting down.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.