Ask your own question, for FREE!
Computer Science 13 Online
OpenStudy (anonymous):

Write a program that prompt the user to enter an integer from 1 to 9, and displays and upside down pyramid . something like this enter number of lines: 5 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 2 1 2 1

OpenStudy (anonymous):

In which Programming language do you want....?

OpenStudy (anonymous):

java

OpenStudy (anonymous):

i can only go this way * * * * * * * * * * * * * * *

OpenStudy (anonymous):

this is my code; for ( i = inpu -1; i >=1 ; i--) { for (int k = 1; k <= i * 2 ; k++) { System.out.print( " " + k ); } System.out.println();

OpenStudy (anonymous):

I will try my level best... give me some time ok...

OpenStudy (anonymous):

okok sure i will try again for the moment thank you.

OpenStudy (anonymous):

if (num < 16) { for (i=1; i<num + 1; i++) { for (j=num-i; j<0; j--) { printf(" "); for (j=i; j<0; j--) { printf(j); } for (j=2; j<i+1; j++) { printf(j); } } } printf(""); } else{ print("The number you have entered is greater than 15."); }

OpenStudy (anonymous):

hey did you get it....?

OpenStudy (anonymous):

mmm well i had it from big to small but now is inverted from small to big

OpenStudy (anonymous):

run: Enter a number: 5 1 2 3 4 5 6 7 8 1 2 3 4 5 6 1 2 3 4 1 2 this what i get from my code

OpenStudy (anonymous):

and should be run: Enter a number: 5 5 4 3 2 1 2 3 4 5 4 3 2 1 2 3 4 3 2 1 2 3 2 1 2 1

OpenStudy (anonymous):

I have the spaces in between okay? the problem is founded here for (int k = 1; k <= i * 2 ; k++) { System.out.print( " " + k);

OpenStudy (anonymous):

now is this way i like it more Enter a number: 5 123456789 12345678 1234567 123456 12345 1234 123 12 1

OpenStudy (anonymous):

Enter a number: 5 12345 1234 123 12 1 Better, but i can still not make it start from 5 or what ever the number i insert

OpenStudy (anonymous):

damnnnnn i do something else but i dont remember how it was before the new code

OpenStudy (anonymous):

public class For { public static void main(String[] args) { for(int i=1;i<=9;i++) { System.out.println(); for(int k=9;k>=i;k--) System.out.print(" "); for(int j=1;j<=i;j++) System.out.print(" *"); } } }

OpenStudy (anonymous):

OpenStudy (anonymous):

i need it inverted!

OpenStudy (anonymous):

and with numbers i made once like that and i try it to inverted but it didn;t woork

OpenStudy (anonymous):

Heres a few pointers/hints. 1. Find the recurring sequences. 2. Try using different steps or even try while loops. 3. Who said you have to use a constant sentinel?

OpenStudy (anonymous):

hihi nobody i'm just trying.

OpenStudy (anonymous):

actually i found that while loops are more helpful than fors'. However, im done with this program wanna helo me with other one?

OpenStudy (anonymous):

im stuck in the loop. -.-. Im a bad programmer

OpenStudy (anonymous):

sure I can help

OpenStudy (anonymous):

sorry i went for food havent eat all day

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!