码迷,mamicode.com
首页 > 其他好文 > 详细

找回感觉的练习

时间:2019-11-06 22:54:40      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:ring   练习   system   com   main   new   val   enc   value   

package feel.java;

public interface Payment {
    public double downPay(double price, double area) ;
}
package feel.java;

/**
 * @author WH
 * @project Java
 * @package feel.java
 * @date 2019/11/6 21:25
 */
public class Residence implements Payment {
    public double downPay(double price, double area) {
        return price * area * 0.2;
    }
}
package feel.java;

/**
 * @author WH
 * @project Java
 * @package feel.java
 * @date 2019/11/6 21:29
 */
public class Commercial implements Payment {
    public double downPay(double price, double area) {
        return price * area * 0.45;
    }
}
package feel.java;

import java.util.Scanner;

/**
 * @author WH
 * @project Java
 * @package feel.java
 * @date 2019/11/6 21:35
 */
public class Feel1 {
        public static void main(String[] args) {
            System.out.println("请输入住宅产权房屋的信息(每平方米的价格 , 总平方数)");
            Scanner en= new Scanner(System.in);
            Residence residence = new Residence();
            double value= residence.downPay(en.nextDouble(), en.nextDouble());
            System.out.println(value);
            System.out.println("请输入商业产权房屋的信息(每平方米的价格 , 总平方数)");
            Payment payment = new Commercial();
            final double value1 = payment.downPay(en.nextDouble(), en.nextDouble());
            System.out.println(value1);
        }
    }

技术图片

 

找回感觉的练习

标签:ring   练习   system   com   main   new   val   enc   value   

原文地址:https://www.cnblogs.com/pbdbk/p/11808906.html

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