我将如何使用三种方法来产生这样的输出?
Please enter the fill character: "z"
Please enter the size of the box (0 to 80): "3"
+---+
|zzz|
|zzz|
|zzz|
+---+
我的代码能够生成一个框,但是我在理解使用其他方法在它周围创建边框时遇到了问题。
import java.util.Scanner;
public class SolidBoxes
{
public static void main(String[] args)
{
int start = 0;
Scanner scan = new Scanner(System.in);
System.out.print("Please enter the fill character: ");
String character = scan.next();
System.out.print("Please enter the size of the box (0 to 80): ");
int size = scan.nextInt();
if ( size > 80 || size < 0)
{
System.out.println("Please enter the size of the box (0 to 80): ");
size = scan.nextInt();
}
for ( int i = 0; i < size; i++)
{
System.out.println();
for ( int j = 0; j < size; j++)
{
System.out.print(character);
}
}
}
}
这给了我输出:
Please enter the fill character: z
Please enter the size of the box (0 to 80): 3
zzz
zzz
zzz
如何为“+---+”和另一种方法“|”添加另外两种方法?