Link to home
Start Free TrialLog in
Avatar of bt1942
bt1942

asked on

write a method called printTriangle. How to start?

(Objects first with java, A practical Introduction using Blue J, Third Ed, David J. Barnes & Michael Kolling)

Hi

I have to write a method called printTriangle.

example:  printTriangle(4);

output should look like this:

*
**
***
****

and I don't know how to start. Can you please give me an advice?
Avatar of chaitu chaitu
chaitu chaitu
Flag of India image

Avatar of bt1942
bt1942

ASKER

chaituu// that seems very complicated, I just need to write a simple method soething like

               
public void printTriangle()
	{
	    int n = 4;
	    String s = "*";
	    for(int row = 1; row<= n; row++)
	    {
	        System.out.println(s);
	      
	       }
	   }
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of javaexperto
javaexperto
Flag of Mexico image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yep, javaexperto, i missed that detail on the new line ; )
SOLUTION
Avatar of glenjr
glenjr
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
looks like i wasnt the only one working on it, i wasnt fast enough :)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bt1942

ASKER

Thanks for your help!