#千峰JAVA逆战班,3月25日#

在千峰逆战班学习的第10天;
JAVA_DAY8;
学习的内容有前一天的作业和方法(函数)return与参数;
中国加油!世界加油!
我自己加油!

/*
设计一个方法,使用*打印正方形。正方形的边长,由参数传入
*/

import java.util.Scanner;

public class Home3Work{
	public static void main(String[]atgs){
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入正方形的边长");
		int side = sc.nextInt();
		if(side<0){
			System.out.println("输入有误");
		}else{
			square(side);
		}
	}
	
	public static void square(int l){
		for(int i = 1;i < l;i++){
			for(int j = 1;j < l;j++){
				System.out.print("*");
			}
			System.out.print("\n");
		}
	}
}
发布了11 篇原创文章 · 获赞 3 · 访问量 390

猜你喜欢

转载自blog.csdn.net/yuxinganggame/article/details/105107807
今日推荐