码迷,mamicode.com
首页 > 编程语言 > 详细

Java

时间:2019-04-26 12:41:48      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:set   static   span   color   package   his   ring   util   private   

package bbb;

    import java.util.Scanner;
     public class ccc {
       Scanner in = new Scanner(System.in);
         private double Lastmonth;
         private double Thismonth;
         public void print()
         {  Double M;
             System.out.println("请输入上个月与这个月的电费读表");
           Lastmonth = in.nextDouble();
           Thismonth= in.nextDouble();
           M=(Thismonth-Lastmonth)*1.2;
           System.out.println("电费为:"+M);
        }
       public double getLastMonth() {
            return Lastmonth;
        }
         public void setLastMonth(double Lastmonth) {
             this.Lastmonth = Lastmonth;
        }
         public double getThisMonth() {
            return Thismonth;
        }
        public void ThisMonth(double Thismonth) {
             Double M;
             this.Thismonth =Thismonth;
             M=(Thismonth)*1.2;
             System.out.println("电费为:"+M);
         }
        
         
     }
package bbb;
import java.util.Scanner;
public class text {
  public static void main(String args[]){
      Scanner in = new Scanner(System.in);
     Double Thismonth;
      ccc c1=new ccc();
      ccc c2=new ccc();
      c1.print();
      c2.print();
      System.out.println("请重新输入本月电费:");
      Thismonth=in.nextDouble();
      c2.ThisMonth(Thismonth);
  }
}

 

Java

标签:set   static   span   color   package   his   ring   util   private   

原文地址:https://www.cnblogs.com/lcc272165/p/10773560.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!