java学习第41天2020/8/15
一.
import java.util.Scanner; public class vehicle { private double a,b; vehicle() { a=12.3;b=11.6; } vehicle(double m,double n){ a=m;b=n; } public double get_a() { return a; } public double get_b() { return b; } public void judge() { if(a>b) { System.out.println("报警!超出最大载重量"); } else { System.out.println("正常"); } } public static void main(String []args) { Scanner input=new Scanner(System.in); vehicle k1=new vehicle(); System.out.println("载重量:"+k1.get_a()+"最大载重量:"+k1.get_b()); k1.judge(); double k,l; System.out.println("请输入载重量与最大载重量:"); k=input.nextDouble(); l=input.nextDouble(); vehicle k2=new vehicle(k,l); k2.judge(); } }
二.无
三.例题