• 1.首家专业真正意义的悬赏问答赚钱网站:ask.book118.com诞生!
  • 2.我们相信:重金之下必有勇者,钱能促进回答!
  • 3.购买答案别害怕,网站有担保,不满意可退款,拒绝恶意操作!
  • 4.回答售出就有80%分成,永久不限次数为您持续产生收益!
  • 5.提问也可以赚钱了,提问所属答案被购买确认,产生10%收益!
  • 6.收益计量都是不限次数、时间、地点,真正意义上的摇钱树!
  • 7.购买者是提问者本人,回答者享有收益100%!
  • 8.自问自答模式已开启!经验/文章博客/聊天记录变问答,好赚钱!
    未登录
    当前位置: 首页 经验之谈 问题详情

    java简易租房管理系统

    发布时间:2019-01-03 17:27 注:该提问由任* 发起的自问自答(由他的知识、经验、图书/文章等拆分演变为问答形式而来),该自问自答产生所有收益的0%归发布人所有。如果你觉得你有更好的回答,也可以参与回答,回答收益分成100%
    以下为提问人的全部回答内容

    D{N}U[B{43XH8L`M[28@H7S.png

    首先建一个包,共7部分代码,结果图先放一下79@D@L9CFEDUUSM9B0K1%]I.png

    下面是代码,复制粘贴就可以了,第一部分

    package building;


    import java.util.Scanner;


    public class BuildingMain {

    public static void main(String[] args) {

    System.out.println("****************************************");

    System.out.println("*                                      *");

    System.out.println("*                                      *");

    System.out.println("*                                      *");

    System.out.println("*                                      *");

    System.out.println("*                 java大厦                           *");

    System.out.println("*                                      *");

    System.out.println("*                                      *");

    System.out.println("*                                      *");

    System.out.println("*                                      *");

    System.out.println("****************************************");

    PayManage payManage = new PayManage();

    RegisterManage register = new RegisterManage();

    RoomManage manage = new RoomManage();

    Scanner scanner = new Scanner(System.in);

    while (true) {

    System.out.println("1.进门登记");

    System.out.println("2.租房");

    System.out.println("3.撤租");

    System.out.println("4.看房");

    System.out.println("5.缴费");

    System.out.println("6.设置缴费金额");

    System.out.println("7.进门记录");

    System.out.println("8.按月份查看缴费");

    System.out.println("9.按房间号看缴费");

    System.out.println("0.退出");

    int num = scanner.nextInt();

    switch (num) {

    case 1: {

    register.add();

    break;

    }

    case 2: {


    manage.rentRoom();

    break;

    }

    case 3: {

    manage.recede();

    break;

    }

    case 4: {

    manage.examineRoom();

    break;

    }

    case 5: {

    payManage.paymanage();

    break;

    }

    case 6: {

    payManage.setpayment();

    break;

    }

    case 7:{

    register.query();

    break;

    }

    case 8:

    {

    System.out.println("请输入月份:");

    int month = scanner.nextInt();

    payManage.MonthserchPay(month);

    break;

    }

    case 9:

    {

    System.out.println("请输入房号:");

    int roomNum = scanner.nextInt();

    payManage.NumserchPay(roomNum);

    break;

    }

    case 0:

    System.exit(0);

    }

    }

    }

    }

            第二部分

    package building;


    import java.util.ArrayList;

    import java.util.Date;

    import java.util.Scanner;


    public class PayManage {

    ArrayList<PaymentList> paymentLists = new ArrayList<PaymentList>();

    Scanner scanner = new Scanner(System.in);


    // 缴费

    public void paymanage() {

    System.out.println("请输入房间号:");

    int num = scanner.nextInt();

    int result = checkArrears(num);

    if (result == 0) {

    System.out.println("您没有欠费记录!");

    } else {

    System.out.println("您有以下费用没有缴纳:");

    for (PaymentList paymentList : paymentLists) {

    if (paymentList.getRoomNum() == num && paymentList.getArrears() != 0)

    System.out.println(paymentList);

    }

    while (true) {

    System.out.println("1.水费");

    System.out.println("2.电费");

    System.out.println("3物业费");

    int select = scanner.nextInt();

    System.out.println("请选择:");

    switch (select) {

    case 1: {

    System.out.println("请输入月份:");

    int month = scanner.nextInt();

    payMoney(num, select, month);

    break;

    }

    case 2: {

    System.out.println("请输入月份:");

    int month = scanner.nextInt();

    payMoney(num, select, month);


    break;

    }

    case 3: {

    System.out.println("请输入月份:");

    int month = scanner.nextInt();

    payMoney(num, select, month);

    break;

    }

    }

    System.out.println("是否退出(y/n)");

    if ("y".equalsIgnoreCase(scanner.next()))

    break;

    }

    }

    }


    public void payMoney(int num, int select, int month) {

    for (PaymentList paymentList : paymentLists) {

    if (paymentList.getRoomNum() == num && paymentList.getType() == select && paymentList.getMonth() == month

    && paymentList.getArrears() != 0) {

    System.out.println("应交电费:" + paymentList.getArrears());

    int money = scanner.nextInt();

    paymentList.setPay(money);

    paymentList.setArrears(0);

    ;

    paymentList.setDate(new Date());

    }

    }

    }


    // 设置缴费

    public void setpayment() {

    System.out.println("请输入月份:");

    int month = scanner.nextInt();

    System.out.println("请输入房间号:");

    int roomNum = scanner.nextInt();

    System.out.println("请输入水费:");

    int water = scanner.nextInt();

    System.out.println("请输入电费:");

    int power = scanner.nextInt();

    System.out.println("请输入物业费:");

    int Property = scanner.nextInt();

    PaymentList list1 = new PaymentList(month, roomNum, 1, water);

    PaymentList list2 = new PaymentList(month, roomNum, 2, power);

    PaymentList list3 = new PaymentList(month, roomNum, 3, Property);

    paymentLists.add(list1);

    paymentLists.add(list2);

    paymentLists.add(list3);


    }


    private int checkArrears(int num) {

    for (PaymentList paymentList : paymentLists) {

    if (paymentList.getRoomNum() == num && paymentList.getArrears() != 0)

    return 1;

    }

    return 0;

    }


    // 按照月份查看收费记录

    public void MonthserchPay(int month) {

    for (PaymentList paymentList : paymentLists) {

    if (paymentList.getMonth() == month) {

    System.out.println(paymentList);

    }


    }

    }


    public void NumserchPay(int roomNum) {

    for (PaymentList paymentList : paymentLists) {

    if (paymentList.getRoomNum() == roomNum) {

    System.out.println(paymentList);

    }


    }

    }

    }

               第三部分

    package building;


    import java.text.SimpleDateFormat;

    import java.util.Calendar;

    import java.util.Date;


    public class PaymentList {

    private int roomNum;

    private Date date;

    private int type;

    private int month;

    private int Arrears;

    private int Pay;

    public PaymentList(int month,int roomNum,int type, int Arrears) {

    super();

    this.month = month;

    this.roomNum = roomNum;

    this.type = type;

    this.Arrears = Arrears;

    }



    public int getRoomNum() {

    展开阅读全文
    0 ID:1730 1人购买 0人评价 好评率:0%
    收起
    0条回答
    抱歉,暂无数据

    本问题战绩报告

    • 访问次数: 212次
    • 收藏次数: 0次
    • 提问收益: 0金币
    • 回答购买: 1笔
    • 累计金额: 50金币

    网站客服

    返回顶部 联系客服 消息中心0