drdallon
New Member
Okay so i have an assignment due 3 days ago in programing, i was sick and couldnt get around to doing it all. I can still turn it in but i need some help i cannot for the life of me figure out how to code this.
The assignment is:
4) Write a class named MakeAPattern that reads a number of lines from the user then makes a pattern of stars in the Run I/O window as follows: If the user enters 7, the output should look exactly like:
*******
******
*****
****
***
**
*
The ‘algorithm’ is: the top line has the same number of stars as the user entered. The next line has one fewer stars, and so on. The last line has only one star.
Hints: You need a nested loop to do this. For the outside loop, use the variable holding the value you read from the user as your counter, and decrement the counter inside the loop instead of incrementing it as we normally do. Use a different counter for the inner loop and initialize it to the value currently held in the outer loop counter.
Finally, use:
System.out.print(‘*’) // caution: not java single quotes
to print a single star and System.out.println() to print an end-of-line.
We are using jGRASP. If some one could code or, or atleast point me in the right direction that would be a HUGE help!
Thank you!
The assignment is:
4) Write a class named MakeAPattern that reads a number of lines from the user then makes a pattern of stars in the Run I/O window as follows: If the user enters 7, the output should look exactly like:
*******
******
*****
****
***
**
*
The ‘algorithm’ is: the top line has the same number of stars as the user entered. The next line has one fewer stars, and so on. The last line has only one star.
Hints: You need a nested loop to do this. For the outside loop, use the variable holding the value you read from the user as your counter, and decrement the counter inside the loop instead of incrementing it as we normally do. Use a different counter for the inner loop and initialize it to the value currently held in the outer loop counter.
Finally, use:
System.out.print(‘*’) // caution: not java single quotes
to print a single star and System.out.println() to print an end-of-line.
We are using jGRASP. If some one could code or, or atleast point me in the right direction that would be a HUGE help!
Thank you!