Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

*Simple* Loop Output question

Status
Not open for further replies.

Perl

Programmer
Aug 24, 2001
2
FR
Howdy , I am trying to write a program which accepts an integer between 1 and 20 and then outputs a progessivly larger hill using 2 different text characters. So for example if I would input a 1 the output would be a


if i input a 2 the output would be a

#
if i input a 3 the output would be a

###
ect....

Right now i am trying to do it with nested for loops but i can't get it working correctly...here is what I have so far


{
public static void main(String [] args)
{
MainWindow mainWindow;
InputBox inputBox;
OutputBox outputBox;
mainWindow = new MainWindow ();
outputBox = new OutputBox (mainWindow);
inputBox = new InputBox (mainWindow);

mainWindow.setVisible( true );
outputBox.setVisible( true );


int hh;
int hhh;
int hill;
int count = 1;



do
{
hill = inputBox.getInteger("Enter an integer between 1 and 20");
}
while (hill > 20 || hill < 1);

outputBox.printLine(&quot;\\&quot;);

for (hh = hill - 1; hh > 0; hh--)
{
outputBox.printLine(&quot;#&quot;);
hh --;

for (hhh = hh - 1; hhh > 0; hhh--)
{
outputBox.printLine(&quot;\\&quot;);
}
}

}
}


any info appricated, thanks!

 
what are you getting ? any error ?
why is the printLine(&quot;\&quot;) INSIDE the other loop ? you need to print it once for each line ....
why are you posting in the __jscript__ forum ?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top