java编写一个应用程序,创建一个圆类,在类中定义半径成员变量、求面积和求周长的方法,
展开全部
import java.util.Scanner;
class Round{
public double perimeter(double radius){
return radius*2;
}
public double area(double radius){
return radius*radius*3.14;
}
public void print(double radius){
System.out.println("圆的周长为-->"+this.perimeter(radius)+"\n"+
"圆的面积为-->"+this.area(radius));
}
}
public class OperateDemo{
public static void main(String args[]){
Round round=new Round();
System.out.print("请输入圆的半径-->");
Scanner scan=new Scanner(System.in);
double radius=scan.nextDouble();
round.print(radius);
}
}
楼主别忘了给分呀~~~
class Round{
public double perimeter(double radius){
return radius*2;
}
public double area(double radius){
return radius*radius*3.14;
}
public void print(double radius){
System.out.println("圆的周长为-->"+this.perimeter(radius)+"\n"+
"圆的面积为-->"+this.area(radius));
}
}
public class OperateDemo{
public static void main(String args[]){
Round round=new Round();
System.out.print("请输入圆的半径-->");
Scanner scan=new Scanner(System.in);
double radius=scan.nextDouble();
round.print(radius);
}
}
楼主别忘了给分呀~~~
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询