写一个家庭收支明细记账软件1.收支明细2.登记收入 3.登记支出 4.退出
假设生活基金为10000元;
记录每次支出/收入明细,并记录下来,以便下次查询;
import java.util.Scanner;
public class jtsz {
public static void main(String[] args) {
String c = "";
Scanner sc = new Scanner(System.in);
boolean bol = true;
while (bol) {
System.out.println("-------------家庭收支记账记录--------------");
System.out.println(" 1 收支明细 ");
System.out.println(" 2 登记收入 ");
System.out.println(" 3 登记支出 ");
System.out.println(" 4 退 出 ");
System.out.println(" 请选择 1-4 ");
int b = 10000;
int x = sc.nextInt();
switch (x) {
case 1:
System.out.println(c);
break;
case 2:
System.out.println("输入收入金额");
int shouru = sc.nextInt();
b += shouru;
System.out.println("输入金额来源");
String s = sc.next();
c += "本次收入金额" + shouru+"\n";
c += "本次收入来源" + s+"\n";
break;
case 3:
System.out.println("输入支出金额");
int zhichu = sc.nextInt();
System.out.println("输入支出细明");
String a = sc.next();
c += "本次支出金额" + zhichu+"\n";
c += "本次支出细明" + a+"\n";
break;
case 4:
bol = false;
break;
}
}
}
}