zoukankan      html  css  js  c++  java
  • 类名大写

         第一、类名要大写(Test);

         第二、可以有多个类,但是只能一个是public。

    import java.util.*;
    
    public class Test 
    {
    	public static void main(String[] args)
    	{
           Scanner sc = new Scanner(System.in);
           double oblength,obheight;
           Oblong myoblong;
           
           System.out.print("please enter the length");
           oblength = sc.nextDouble();
           System.out.print("please enter the height");
           obheight = sc.nextDouble();
           
           myoblong = new Oblong(oblength,obheight);
           System.out.println("length="+myoblong.getLength());
           System.out.println("height="+myoblong.getHeight());
           System.out.println("area="+myoblong.calculateArea());
           System.out.println("perimeter="+myoblong.calculatePerimeter());
    	}
    	
    }
    
    
    class Oblong
    {
      private double length;
      private double height;
      
      public Oblong(double a,double b)
      {
    	  length = a;
    	  height = b;
      }
      
      public double getLength()
      {
    	  return length;
      }
      public double getHeight()
      {
    	  return height;
      }
      public double calculateArea()
      {
    	  return length * height;
      }
      public double calculatePerimeter()
      {
    	  return 2*(length + height);
      }
    }
    
  • 相关阅读:
    leetcode刷题29
    leetcode刷题28
    leetcode刷题27
    leetcode刷题23
    leetcode刷题22
    leetcode刷题21
    leetcode刷题20
    Unity中通过DoTween实现转盘效果
    U3D工作注意事项,不要再犯!
    Unity中String字符串的优化
  • 原文地址:https://www.cnblogs.com/HpuAcmer/p/2378454.html
Copyright © 2011-2022 走看看