nested for loops

what is the programming code to make a program that will ask the user to input the height of a mountain?

for example, if they input 4 as the height of the mountain, the program should say but inverted, with the tip of the mountain touching the left and the base on the right:

*

**

***

****

***

**

*

[354 byte] By [x3virgiea] at [2007-11-27 9:41:36]
# 1
Summer school?
BigDaddyLoveHandlesa at 2007-7-12 23:20:51 > top of Java-index,Java Essentials,Java Programming...
# 2

Play with the for loops. Do you know what nested for loops are?

for(int i=0; i<number; i++){

for(int j=0; j>< someothernumber; j++){

for(int k=0;k<somenumber;k++{

}//end for k

}//end for j

}//end for for i

Play around with things like that and you'll get it.

Btw, don't get the Iphone, sales must not reach 1.5 million.

->

blackmagea at 2007-7-12 23:20:51 > top of Java-index,Java Essentials,Java Programming...
# 3
> what is the programming code I doubt anyone here is giving you the full code but if you need help just show us your code and tell us whats wrong so we can take a look.
deAppela at 2007-7-12 23:20:51 > top of Java-index,Java Essentials,Java Programming...
# 4
Why must sales not reach 1.5M?
lamar_aira at 2007-7-12 23:20:51 > top of Java-index,Java Essentials,Java Programming...
# 5
> Why must sales not reach 1.5M?Long Story
blackmagea at 2007-7-12 23:20:51 > top of Java-index,Java Essentials,Java Programming...
# 6
ok
lamar_aira at 2007-7-12 23:20:51 > top of Java-index,Java Essentials,Java Programming...
# 7
> > Why must sales not reach 1.5M?> > Long StoryWell, we've got time. The OP isn't going to ever post again, I bet.
BigDaddyLoveHandlesa at 2007-7-12 23:20:51 > top of Java-index,Java Essentials,Java Programming...
# 8
> > Why must sales not reach 1.5M?> > Long StoryYeah, just 40 pages or so :-)
_helloWorld_a at 2007-7-12 23:20:51 > top of Java-index,Java Essentials,Java Programming...
# 9
> > Why must sales not reach 1.5M?> > Long StoryEven longer thread
georgemca at 2007-7-12 23:20:51 > top of Java-index,Java Essentials,Java Programming...
# 10

import java.util.Scanner;

class mountain

{

public static void main (String args[])

{

Scanner input = new Scanner ( System.in );

int i,j, num;

System.out.print("Enter height of the mountain: ");

num=input.nextInt();

{for(i=0; i<=num;i++)

{for(j=1;j<i;j++)

System.out.println(" ");

{System.out.print("*");

}

}

}

{for(i=0;i<num;i++)

{for(j=num;j>i;j--)

System.out.println(" ");

{System.out.print("*");

}

}

}

}

}

that is the code for the original one but we need to invert it.

x3virgiea at 2007-7-12 23:20:51 > top of Java-index,Java Essentials,Java Programming...
# 11
You proved me wrong! I thought you wouldn't post again.But do you have a specific question?
BigDaddyLoveHandlesa at 2007-7-12 23:20:51 > top of Java-index,Java Essentials,Java Programming...
# 12
my question is:how do you invert the original mountain?
x3virgiea at 2007-7-12 23:20:51 > top of Java-index,Java Essentials,Java Programming...
# 13
For starters, note the difference between print and println, and ask yourself, "when do I need to terminate the current line by writing the line separator string?".
BigDaddyLoveHandlesa at 2007-7-12 23:20:51 > top of Java-index,Java Essentials,Java Programming...