写一个家庭收支明细记账软件1.收支明细2.登记收入 3.登记支出 4.退出
假设生活基金为10000元;
记录每次支出/收入明细,并记录下来,以便下次查询;
package lianxi;
import java.util.Scanner;
public class bc02 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int money = 10000;
String z = "";
String s = "";
t:while(true) {
System.out.println("-------家庭收支记账软件-------");
System.out.println("1.收支明细");
System.out.println("2.登记收入 ");
System.out.println("3.登记支出");
System.out.println("4.退出");
int c = sc.nextInt();
if (c == 1)//收支明细
{
System.out.println("家庭收入明细\n" + s +"元\n" + "家庭支出明细\n" + z+"元");
System.out.println("剩余金额"+money+"元");
}
if (c == 2)//登记收入
{
System.out.println("输入金额");
int c2 = sc.nextInt();
System.out.println("输入用途");
String b = sc.next();
money = money + c2;
b=b+c2;
s += b;
System.out.println("本次收入金额:" + c2);
System.out.println("本次收入说明:" + b);
}
if (c == 3)//登记支出
{
System.out.println("输入金额");
int c3 = sc.nextInt();
System.out.println("输入用途");
String d = sc.next();
money = money - c3;
d=d+c3;
z += d;
System.out.println("本次支出金额:" + c3);
System.out.println("本次支出说明:" + d);
}
if (c == 4)//退出
{
break t;
}
}
}
}