阅读背景:

需要使用*和方法制作一个盒子

来源:互联网 
package methods;

import java.util.Scanner;

public class DisplayBox {

    public static void box (int dimensions){ 

         for (int i = 0; i < dimensions; i++) {
                for (int j = 0; j < dimensions; j++) {
                    System.out.print(" *");
                }
                System.out.println("");
            }        

    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        Scanner input = new Scanner (System.in);  

        int length, width ; 

        System.out.println ("Please enter the length of the box"); 
        length = input.nextInt();
        System.out.println (" Please enter the width of the box");
        width = input.nextInt(); 

        input.close(); 


        box (length); 
        box (width);


    }

}
package methods;

import java.util.Scanner;

pu



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: