zoukankan      html  css  js  c++  java
  • java第4次作业

    package JavaPractice;
    2 class ElectricCharge
    3 {
    4 private double lastnum,thisnum;
    5 public ElectricCharge()
    6 {
    7
    8 }
    9 public ElectricCharge(double lastnum, double thisnum)
    10 {
    11 this.lastnum = lastnum;
    12 this.thisnum = thisnum;
    13 }
    14 public double getLastnum()
    15 {
    16 return lastnum;
    17 }
    18 public void setLastnum(double lastnum)
    19 {
    20 this.lastnum = lastnum;
    21 }
    22 public double getThisnum()
    23 {
    24 return thisnum;
    25 }
    26 public void setThisnum(double thisnum)
    27 {
    28 this.thisnum = thisnum;
    29 }
    30 public void PrintMessage()
    31 {
    32 System.out.println("上月用电为:"+lastnum+" 本月用电为:"+thisnum);
    33 }
    34
    35 }
    36 public class TestEC
    37 {
    38 public static void main(String[] args)
    39 {
    40 ElectricCharge ec1=new ElectricCharge();
    41 ec1.setLastnum(1000);
    42 ec1.setThisnum(1200);
    43 System.out.println("用户一家的用电情况为:");
    44 ec1.PrintMessage();
    45 System.out.println("本月电费为:"+ec1.getThisnum()1.2);
    46 System.out.println();
    47
    48 ElectricCharge ec2=new ElectricCharge(1200,1450);
    49 ec2.setThisnum(1500);
    50 System.out.println("用户二家的用电情况为:");
    51 ec2.PrintMessage();
    52 System.out.println("本月电费为:"+ec2.getThisnum()
    1.2);
    53
    54
    55 }
    56 }

  • 相关阅读:
    第十一节 jQuery特殊效果
    第十节 使用index和一个点击事件实现选项卡
    synchronized和lock两种锁的比较
    常见的四种线程池和区别
    mybatis中的#和$的区别
    web 防止SQL注入
    GIT配置免密登录
    热点 Key 问题的发现与解决
    Redis缓存击穿
    面试必问之JVM原理
  • 原文地址:https://www.cnblogs.com/nicejun/p/10995178.html
Copyright © 2011-2022 走看看