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 }

  • 相关阅读:
    golang动态加载原生代码思路
    boltdb的实现和改进
    如何保证数据掉电不损坏?
    msgpack库的神奇用法
    消息推送与同步协议的思考
    cassandra的gc调优
    tcp链接断开的探测
    加速和监控国际网络
    轻松逃脱某防火墙对ss的探测
    java文件操作之war压缩解压
  • 原文地址:https://www.cnblogs.com/nicejun/p/10995178.html
Copyright © 2011-2022 走看看