飞行的猪哼哼

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Problem Description

根据读入的正方形的边长(边长为正整数),输出其正方形的面积。
Input

输入数据含有多个的正方形(个数不确定)的边长a(1≤a≤10000),每个边长之间以空格隔开。
Output

每次读入一个边长,便输出其正方形的面积,每一行输出一个正方形的面积。
Sample Input

1 3
Sample Output

1
9


import java.util.Scanner;

import javax.print.attribute.standard.PrinterLocation;

public class Main
{

	public static void main(String[] args)
{
	Scanner reader = new Scanner(System.in);
    while(reader.hasNext())
	{
		int x=reader.nextInt();
		Size S=new Size(x);
		int y=S.div();
		System.out.printf("%d\n",y);
	}
	reader.close();

}
}
 
 class Size
 {
	 int x;
	 public Size(int x)
	 {
		 this.x=x;
	 }
	 public int div()
	 {
		 return x*x;
	 }
 }
posted on 2018-10-13 15:55  飞行的猪哼哼  阅读(76)  评论(0)    收藏  举报