找回感觉的练习
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); } }