+ 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: ***** *** *********
4 Respuestas
+ 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);
}
}
+ 6
Xanadu2112 Solution : 💗 🙆♂️🤗
https://code.sololearn.com/coxncuah28i2/?ref=app
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++;
}
}
0
Dänks!!