+ 2

Im stuck..Can u pls help me how to create a method for printing a star?;-;

private static void printStars(int amount) { //you can print one star with the command //sout(”*”) //call this command amound times } public static void main(String[] args) { printStars(5); printStars(3); printStars(9); } The program output: ***** *** *********

5th Sep 2018, 10:42 PM
Xanadu2112
Xanadu2112 - avatar
4 Answers
+ 1
class Discuss { public static void printStars(int amount) { while(amount!=0) { System.out.print("*"); amount--; } System.out.println(); } public static void main(String[] args) { printStars(5); printStars(3); printStars(9); } }
6th Sep 2018, 2:13 PM
Varun Maheshwari
Varun Maheshwari - avatar
+ 6
Xanadu2112 Solution : 💗 đŸ™†â€â™‚ïžđŸ€— https://code.sololearn.com/coxncuah28i2/?ref=app
5th Sep 2018, 11:13 PM
NimWing Yuan
NimWing Yuan - avatar
0
When I tried this solution on Netbeans, it just prints infinity amount of * D: public static void main(String[] args) { printStars(5); printStars(3); printStars(9); } public static void printStars(int n) { int i = 1; while (1 <= n) { System.out.println("*"); System.out.println(""); i++; } }
6th Sep 2018, 7:49 AM
Xanadu2112
Xanadu2112 - avatar
0
DĂ€nks!!
7th Sep 2018, 10:20 AM
Xanadu2112
Xanadu2112 - avatar