Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I make a box out of a star (*) using loops, like the one I done for a square, see code below.

import java.util.*;
public class g {
public static void main(String[]args){
Scanner input=new Scanner(System.in);

System.out.println("Enter a number");
int x=input.nextInt();
for(int h=0;h<;x;h++){
for(int k=0;k<;x;k++)
System.out.print("*");
System.out.println();


}
}

}
Posted

1 solution

This is obviously homework . Look at the output you're getting and ask yourself how you'd need to change it to get the result you want.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900