public class FamilyAccount {
public static void main(String[] args) {
boolean isFlag=true;
String details="收支\t账户金额\t收支金额\t说 明\n";
//初始金额
int balance=10000;
while(isFlag){
System.out.println("-----------------家庭收支记账软件-----------------");
System.out.println(" 1 收支明细");
System.out.println(" 2 登记收入");
System.out.println(" 3 登记支出");
System.out.println(" 4 退 出\n");
System.out.println(" 请选择(1-4):");
//获取用户的选择
char selection= Tool.readMenuSelector();
switch(selection){
case '1':
System.out.println("-----------------当前收支明细记录-----------------");
System.out.println(details);
System.out.println("--------------------------------------------------");
break;
case '2':
System.out.print("本次收入金额:");
int money1=Tool.readNumber();
System.out.print("本次收入说明:");
String info1=Tool.readString();
balance=balance+money1;
details+="收入\t"+balance+"\t\t"+money1+"\t\t\t"+info1+"\n";
System.out.println("---------------------登记完成---------------------");
break;
case '3':
System.out.print("本次支出金额:");
int money2 = Tool.readNumber();
System.out.print("本次支出说明:");
String info2 = Tool.readString();
if(money2<=balance) {
balance -= money2;
details += "支出\t" + balance + "\t\t" +
money2 + "\t\t\t" + info2 + "\n";
}
else
System.out.println("支出超出账户额度!支付失败");
System.out.println("---------------------登记完成---------------------");
break;
case '4':
System.out.print("确认是否退出!Y/N");
char isExit= Tool.readConfirmSelection();
if(isExit=='Y')
{
isFlag=false;
}
break;
}
}
}
}
Monster:(
- 粉丝: 20
- 资源: 2
最新资源
- Linux Lab-linux
- ioGame-unity
- kdump-anaconda-addon-anaconda
- northstar-ai
- basic_framework-keil5安装教程
- 守月亮修行杂谈(2012年-2020年)
- 《Web开发实训》项目总结报告.doc
- 新年烟花LED效果,10分频,10khz变1khz,Multisim仿真
- vba自定清单.zip
- XamarinBleCodeBehind-main.zip
- mmexport1734999482214.png
- python-4.FBI树-虽然但是,不是那个.py
- IMG_20241220_204418_edit_64163654257396.png
- python-5.火星人-这题面,好抽象.py
- python-6.奖学金-语文给你多少?我数英给你…….py
- Screenshot_20241216_213107.jpg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈