Java实验题3_3_林大锐格平台
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java实验题3_3_林大锐格平台相关的知识,希望对你有一定的参考价值。
import java.util.Scanner; abstract class Shape{ abstract float GetArea(); abstract float GetPerimeter(); } class Rectangle{ private double x,y; public Rectangle(int i, int j) { x=i; y=j; } public float GetArea(){ return (float)(x*y); } public float GetPerimeter(){ return (float)((x+y)*2) ; } //write code here } class Circle{ private double a; public Circle(int i) { a=i; } public float GetArea(){ return (float)(a*3.14*a); } public float GetPerimeter(){ return (float)(3.14*2*a); } //write code here } public class Main{ public static void main(String[] args){ Scanner sca = new Scanner(System.in); int a = sca.nextInt(); int b = sca.nextInt(); int r = sca.nextInt(); Rectangle aa = new Rectangle(a,b); System.out.println(aa.GetArea()); System.out.println(aa.GetPerimeter()); Circle c = new Circle(r); System.out.println(c.GetArea()); System.out.println(c.GetPerimeter()); } }
以上是关于Java实验题3_3_林大锐格平台的主要内容,如果未能解决你的问题,请参考以下文章