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

  

时间: 2025-01-02 09:29:15

Java实验题3_3_林大锐格平台的相关文章

Java实验题3_8_林大锐格平台

import java.util.Scanner; class Employee { private String name;// 职员名称 public Employee() { }; public Employee(String s) {// 构造函数,初始化职员名称 this.name = s; } public String GetName() { // 获取职员名称 return name; } } class Manager extends Employee{ String depa

Java实验题3_7_林大锐格平台

import java.util.Scanner; abstract class Vehicle { String wheels; abstract String noOfWheels(String a); void showWheels(){ System.out.println(wheels+" wheel vehicle"); } //write your own codes } class Car extends Vehicle { public String noOfWhee

Java实验题3_4_林大锐格平台

import java.util.Scanner; abstract class Animal { public String name; public int age; public float weight; public void showInfo() { System.out.println("name:" + this.name + " age:" + this.age + " weight:" + this.weight); } pu

Java实验题3_5_林大锐格平台

import java.util.Scanner; //write code here class Dog{ String breed,color;int weight; } class SpottedDog extends Dog{ private String spotColor; SpottedDog(String a,int b,String c,String d){ breed=a;weight=b;color=c;spotColor=d; } void showBreed(){ Sy

Java实验题3_1_林大锐格平台

import java.util.Scanner; interface ShowMessage{ void showTradeMark(); } class TV implements ShowMessage{ String a; TV(String a) { this.a=a; } public void showTradeMark() { System.out.println("I am TV "+a); } } public class Main{ public static v

Java练习题4_last_1042林大锐格平台

import java.util.Scanner; public class Main{ public static void main(String args[]){ int ri , repeat; int n; Scanner in = new Scanner(System.in); repeat = in.nextInt(); for(ri = 1 ; ri <= repeat ; ri++){ n=in.nextInt(); dectobin(n); } } static void d

Java练习题4_last-1_1043林大锐格平台

import java.util.Scanner; public class Main{ public static void main(String[] args){ int m , n; Scanner in = new Scanner(System.in); m = in.nextInt(); n = in.nextInt(); System.out.println(Min(m,n)); } static int Min(int a,int b){ if(a<=b)return a; el

Java练习题4_3_2407林大锐格平台

import java.util.Scanner; class Rectangular { private static int x, y; private static int countP = 0; public Rectangular(int xx, int yy) { x=xx; y=yy; } public Rectangular(Rectangular p) { x=p.x; y=p.y; } public int getX() { return x; } public int ge

HDU 1715 大菲波数(JAVA, 简单题,大数)

题目 //BigInteger 和 BigDecimal 是在java.math包中已有的类,前者表示整数,后者表示浮点数 import java.io.*; import java.util.*; import java.math.*; public class Main { /** * @xqq */ public BigInteger an(BigInteger a, BigInteger b, int n) { if(n == 1) { return a; } for(int i = 2