第三次上机

 1 public class fouth_fomework {
 2        final double fire = 1.2;
 3        static double last_month;
 4        static double this_month;
 5        public void setlastmonthpower(double change){
 6            this.last_month = change;
 7        }
 8        public double getlastmonthpower(){
 9            return this.last_month;
10        }
11        public void setthismonthpower(double change){
12            this.this_month = change;
13        }
14        public double getthismonthpower() {
15            return this.this_month;
16        }
17        public double compute(double last_month,double this_name){
18            return (this_name-last_month)*fire;
19        }
20   public static void main(String[] args) {
21         fouth_fomework p1 = new fouth_fomework();
22         fouth_fomework p2 = new fouth_fomework();
23         p1.setlastmonthpower(1000);
24         p1.setthismonthpower(1200);
25         p2.setlastmonthpower(1200);
26         p2.setthismonthpower(1450);
27         System.out.println("本月电费为:");
28         System.out.println (p1.compute(p1.getlastmonthpower(),p1.getthismonthpower()));
29         p2.setthismonthpower(1500);
30         System.out.println("本月电费为:");
31         System.out.println(p2.compute(p2.getlastmonthpower(),p2.getthismonthpower()));
32     }
33 
34 }

 

posted @ 2019-04-28 13:35  一个人的姐姐  阅读(132)  评论(0编辑  收藏  举报