4个回答
展开全部
package cn.gdsdxy;
import java.util.Scanner;
public class MainClass {
public static void main(String[] args) {
SquareClass obj1 = new SquareClass();
Scanner in = new Scanner(System.in);
int len = in.nextInt();
obj1.setLength(len);
System.out.println(obj1.getArea());
SquareClass obj2 = new SquareClass(10d);
System.out.println(obj2.getArea());
double length = in.nextDouble();
SquareClass obj3 = new SquareClass(length);
System.out.println(obj3.getArea());
}
static class SquareClass {
double length;
double getArea() {
double area = length * length;
return area;
}
public SquareClass(double len) {
this.length = len;
}
SquareClass() {
}
public double getLength() {
return length;
}
public void setLength(double length) {
this.length = length;
}
}
}
import java.util.Scanner;
public class MainClass {
public static void main(String[] args) {
SquareClass obj1 = new SquareClass();
Scanner in = new Scanner(System.in);
int len = in.nextInt();
obj1.setLength(len);
System.out.println(obj1.getArea());
SquareClass obj2 = new SquareClass(10d);
System.out.println(obj2.getArea());
double length = in.nextDouble();
SquareClass obj3 = new SquareClass(length);
System.out.println(obj3.getArea());
}
static class SquareClass {
double length;
double getArea() {
double area = length * length;
return area;
}
public SquareClass(double len) {
this.length = len;
}
SquareClass() {
}
public double getLength() {
return length;
}
public void setLength(double length) {
this.length = length;
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
学识不够,SOrry不知道什么问题
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2020-03-04
展开全部
楼下哪位正解,答案基本正确
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询