正方形面积

版权声明:禁止转载,翻版必究 https://blog.csdn.net/qq_41341757/article/details/83039363

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;
	 }
 }

猜你喜欢

转载自blog.csdn.net/qq_41341757/article/details/83039363