首页 > 其他 > 详细

找回感觉的练习

时间:2019-11-06 22:07:10      阅读:79      评论:0      收藏:0      [点我收藏+]
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);
        }
    }

技术分享图片

 

找回感觉的练习

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!