yamahafzr
Regular Member
- Mar 29, 2009
- 246
- 154
Hey, I am doing basic java and we are doing some pyramids and I am really struggling. I really want to learn java, so if anyone would be nice enough to help me out please let me know. I would think it would be easier to do it over aim rather then do it over the thread, but basically i have to make 4 pyramids
*
**
***
****
*****
*****
****
***
**
*
-----------------*
---------------*-- *
-------------* --* --*
-----------* --* --* --*
---------*-- *-- *-- *-- *
edit: fuck the above one took out the spaces so im gunna replace the spaces wit -
and the above one flipped. I got the first 2, but i can't get the second 2. Also, they have to rely on the input, so for the above pyramids the input was 5. The input is between 1-20. Any help is greatly appreciated
edit: wat i have for the top 2. this is our level of coding
the cherokee. is from a class file that he made and we put it in the bottom of our code
final edit: we can only use 2 loops per pyramid
*
**
***
****
*****
*****
****
***
**
*
-----------------*
---------------*-- *
-------------* --* --*
-----------* --* --* --*
---------*-- *-- *-- *-- *
edit: fuck the above one took out the spaces so im gunna replace the spaces wit -
and the above one flipped. I got the first 2, but i can't get the second 2. Also, they have to rely on the input, so for the above pyramids the input was 5. The input is between 1-20. Any help is greatly appreciated
edit: wat i have for the top 2. this is our level of coding
Code:
package loops;
import java.io.*;
public class Main {
public static void main(String[] args) {
int userinput = 0;
do
{
System.out.println("enter number less than 18");
userinput = Cherokee.readInt();
}while(userinput>= 18 && userinput<1);
for(int x = 0;x<=userinput;)
{
for (int y = 0;y<x;y++)
System.out.print("*");
System.out.println("");
x++;
}
System.out.println(" ");
for(int x = 0;x<userinput;)
{
for (int y = 0;y<userinput;)
{
if(x>y)
System.out.print(" ");
else
System.out.print("*");
y++;
}
System.out.println("");
x++;
}
System.out.println(" ");
}
}
final edit: we can only use 2 loops per pyramid
Last edited: