• 第十次作业


    package Test;
    
    import java.util.Scanner;
    
    public class test13 {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            Buyer buyer = new Buyer();
            buyer.name = "Lisa";
            Intermediary inter = new Intermediary(buyer);
            double price = 0.0;
            Scanner reader = new Scanner(System.in);
            System.out.println("请输入房屋的总价格:");
            price = reader.nextDouble();
            inter.charing(price);
        }
    }
    interface Business{
        //房屋中介费 0.022
        double RATIO = 0.0;
        //代表购房税费
        double TAX = 0.0;
        //price表示房屋总价
        default void Buying(double price) {}
    }
    class Buyer implements Business{
        String name ;
        @Override
        public void Buying(double price) {
            // TODO Auto-generated method stub
            System.out.println(name +"购买一套住宅的价格是:"+price);
        }
    }
    class Intermediary implements Business{
        //购房对象
        Buyer buyer ;
        public Intermediary(Buyer buyer) {
            this.buyer = buyer;
        }
    
        @Override
        public void Buying(double price) {
            // TODO Auto-generated method stub
        }
        public void charing(double price) {
            System.out.println(buyer.name+"购买一套"+price+"的住宅需要花费"+price*0.022+"的房屋中介费和"+price*0.03+"的契税费");
        }
    }

    package Test;
    
    import java.util.Scanner;
    
    public class test12 {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            double total = 0.0;
            Scanner scanner = new Scanner(System.in);
            for(int i = 0;i < 5;i++) {
                double score = scanner.nextDouble();
                if(score>100||score<0) {
                    throw new myException1234("分数不能大于100或者小于0");
                }
                total += score;
            }
            System.out.println("分数的平均值是:"+total/5);
        }
    }
    class myException1234 extends RuntimeException{
        
        myException1234(String msg){
            super(msg);
        }
    }

  • 相关阅读:
    342. Power of Four(One-line)
    mysql的启动,停止与重启
    PHP学习笔记之interface关键字
    PHP学习笔记之析构函数以及static,self,parent关键字
    每天一个linux命令(1):ln 命令
    MySQL学习笔记:regexp正则表达式
    AARRR:数据运营模型
    MySQL学习笔记:从一个表update到另外一个表
    MySQL学习笔记:计算机服务中找不到MySQL服务
    MySQL学习笔记:insert into select
  • 原文地址:https://www.cnblogs.com/xiexiaofei/p/11848405.html
Copyright © 2020-2023  润新知