JAVA简单易上手的记账软件------JAVA

 //工具

import java.util.Scanner;
public class Utility
{
    static Scanner in = new Scanner(System.in);
    public static char readMenuSelection()
    {
        char c;
        while(true)
        {
            String str = readKeyBoard(1);
            c = str.charAt(0);
            if(c != '1' && c != '2' && c != '3' && c != '4')
            {
                System.out.println("输入错误");
            }
            else
            {
                break;
            }
        }
        return c;
    }


    public static int readNumber()
    {
        int n;
        while(true)
        {
            String str = readKeyBoard(4);
            try
            {
                n = Integer.parseInt(str);
                break;
            }
            catch (NumberFormatException e)
            {
                System.out.println("输入错误,请重新输入");
            }
        }
        return n;
    }


    public static String readString()
    {
        String str = readKeyBoard(8);
        return str;
    }


    public static char readConfirmSelection()
    {
        char c;
        while(true)
        {
            String str = readKeyBoard(1).toUpperCase();
            c = str.charAt(0);
            if(c == 'Y' || c == 'N')
            {
                break;
            }
            else
            {
                System.out.println("选择错误,请重新输入");
            }
        }
        return c;
    }


    private static String readKeyBoard(int limit)
    {
        String line = "";
        while(in.hasNext())
        {
            line = in.nextLine();
            if(line.length() < 1 || line.length() > limit)
            {
                System.out.print("输入长度(不大于" + limit + ")错误,请重新输入:");
                continue;
            }
            else
            {
                break;
            }
        }
        return line;
    }
}
import java.util.Scanner;
public class Utility
{
    static Scanner in = new Scanner(System.in);
    public static char readMenuSelection()
    {
        char c;
        while(true)
        {
            String str = readKeyBoard(1);
            c = str.charAt(0);
            if(c != '1' && c != '2' && c != '3' && c != '4')
            {
                System.out.println("输入错误");
            }
            else
            {
                break;
            }
        }
        return c;
    }


    public static int readNumber()
    {
        int n;
        while(true)
        {
            String str = readKeyBoard(4);
            try
            {
                n = Integer.parseInt(str);
                break;
            }
            catch (NumberFormatException e)
            {
                System.out.println("输入错误,请重新输入");
            }
        }
        return n;
    }


    public static String readString()
    {
        String str = readKeyBoard(8);
        return str;
    }


    public static char readConfirmSelection()
    {
        char c;
        while(true)
        {
            String str = readKeyBoard(1).toUpperCase();
            c = str.charAt(0);
            if(c == 'Y' || c == 'N')
            {
                break;
            }
            else
            {
                System.out.println("选择错误,请重新输入");
            }
        }
        return c;
    }


    private static String readKeyBoard(int limit)
    {
        String line = "";
        while(in.hasNext())
        {
            line = in.nextLine();
            if(line.length() < 1 || line.length() > limit)
            {
                System.out.print("输入长度(不大于" + limit + ")错误,请重新输入:");
                continue;
            }
            else
            {
                break;
            }
        }
        return line;
    }
}

//主函数

class program
{
    public static void main(String args[])
    {
        boolean isFlag = true;
        int balance = 10000;
        String InInfo = "";
        String OutInfo = "";
        while(isFlag == true)
        {
            System.out.println("---------------记账软件---------------");
            System.out.println("              1.收支明细              ");
            System.out.println("              2.登记收入              ");
            System.out.println("              3.登记支出              ");
            System.out.println("              4. 退  出\n             ");
            System.out.print("              请选择(1-4):             ");

            char selection = Utility.readMenuSelection();
            switch (selection)
            {
                case '1':
                {
                    System.out.println("\t当前收支明细记录\t");
                    System.out.println("收支\t账户金额\t收支金额\t说明\n");
                    System.out.println(InInfo);
                    System.out.println(OutInfo);
                    System.out.println("\t当前收支明细记录\t");
                    break;
                }
                case '2':
                {
                    System.out.println("\t本次收入金额\t");
                    int income = Utility.readNumber();
                    if(income > 0)
                    {
                        balance = income + balance;
                        System.out.println("\t本次收入类型\t");
                        String InText = Utility.readString();
                        InInfo = InInfo + "收入\t" + balance + "\t" + "income" + "\t" + InText + "\n";
                    }
                    else
                    {
                        System.out.println("金额错误,请重新输入");
                    }
                    break;
                }
                case '3':
                {
                    System.out.println("\t本次支出金额\t");
                    int outcome = Utility.readNumber();
                    balance = balance - outcome;
                    System.out.println("\t本次支出类型\t");
                    String OutText = Utility.readString();
                    OutInfo = OutInfo + "支出\t" + balance + "\t" + "outcome" + "\t" + OutText + "\n";
                    break;
                }
                case '4':
                {
                    System.out.println("您是否要退出");
                    char isExit = Utility.readConfirmSelection();
                    if(isExit == 'Y')
                    {
                        isFlag = false;
                    }
                    break;
                }
            }

        }
    }
}
class program
{
    public static void main(String args[])
    {
        boolean isFlag = true;
        int balance = 10000;
        String InInfo = "";
        String OutInfo = "";
        while(isFlag == true)
        {
            System.out.println("---------------记账软件---------------");
            System.out.println("              1.收支明细              ");
            System.out.println("              2.登记收入              ");
            System.out.println("              3.登记支出              ");
            System.out.println("              4. 退  出\n             ");
            System.out.print("              请选择(1-4):             ");

            char selection = Utility.readMenuSelection();
            switch (selection)
            {
                case '1':
                {
                    System.out.println("\t当前收支明细记录\t");
                    System.out.println("收支\t账户金额\t收支金额\t说明\n");
                    System.out.println(InInfo);
                    System.out.println(OutInfo);
                    System.out.println("\t当前收支明细记录\t");
                    break;
                }
                case '2':
                {
                    System.out.println("\t本次收入金额\t");
                    int income = Utility.readNumber();
                    if(income > 0)
                    {
                        balance = income + balance;
                        System.out.println("\t本次收入类型\t");
                        String InText = Utility.readString();
                        InInfo = InInfo + "收入\t" + balance + "\t" + "income" + "\t" + InText + "\n";
                    }
                    else
                    {
                        System.out.println("金额错误,请重新输入");
                    }
                    break;
                }
                case '3':
                {
                    System.out.println("\t本次支出金额\t");
                    int outcome = Utility.readNumber();
                    balance = balance - outcome;
                    System.out.println("\t本次支出类型\t");
                    String OutText = Utility.readString();
                    OutInfo = OutInfo + "支出\t" + balance + "\t" + "outcome" + "\t" + OutText + "\n";
                    break;
                }
                case '4':
                {
                    System.out.println("您是否要退出");
                    char isExit = Utility.readConfirmSelection();
                    if(isExit == 'Y')
                    {
                        isFlag = false;
                    }
                    break;
                }
            }

        }
    }
}

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
java语言写的android系统,用于个人账目管理,课程设计上写的欢迎下载 package moneymanager.moneymanager; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; /* * * 데이터베이스를 관리하는 클래스입니다. * */ public class DBAdapter { private static final String TAG = "NotesDbAdapter"; private DatabaseHelper mDbHelper; private SQLiteDatabase mDb; // 데이터베이스이름과 테블이름들을 정의 private static final String DATABASE_NAME = "MoneyManagerDB"; private static final int DATABASE_VERSION = 2; private static final String DATABASE_SETTING_TABLE = "SettingTbl"; private static final String DATABASE_BADGET_TABLE = "BadgetTbl"; private static final String DATABASE_PAYMENT_TABLE = "PaymentTbl"; // 테블안의 항목들을 정의 public static final String KEY_SETTINGTBL_ID = "ID"; public static final String KEY_SETTINGTBL_NAME = "Name"; public static final String KEY_SETTINGTBL_VALUE = "Value"; public static final String KEY_BADGETTBL_ID = "ID"; public static final String KEY_BADGETTBL_ITEM = "Item"; public static final String KEY_BADGETTBL_MONEY = "Money"; public static final String KEY_PAYMENTTBL_ID = "ID"; public static final String KEY_PAYMENTTBL_BADGETID = "BadgetID"; public static final String KEY_PAYMENTTBL_OUTDATE = "OutDate"; public static final String KEY_PAYMENTTBL_MONEY = "Money"; public static final String KEY_PAYMENTTBL_NOTE = "Note"; private final Context mCtx; private static class DatabaseHelper extends SQLiteOpenHelper { DatabaseHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { String strCreateTbl; // SettingTbl생성 strCreateTbl = "CREATE TABLE " + DATABASE_SETTING_TABLE + " (" + KEY_SETTINGTBL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_SETTINGTBL_NAME + " TEXT NOT NULL, " + KEY_SETTINGTBL_VALUE + " TEXT NOT NULL);"; db.execSQL(strCreateTbl); // BadgetTbl생성 strCreateTbl = "CREATE TABLE " + DATABASE_BADGET_TABLE + " (" + KEY_BADGETTBL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_BADGETTBL_ITEM + " TEXT NOT NULL, " + KEY_BADGETTBL_MONEY + " INTEGER NOT NULL);"; db.execSQL(strCreateTbl); // PaymentTbl생성 strCreateTbl = "CREATE TABLE " + DATABASE_PAYMENT_TABLE + " (" + KEY_PAYMENTTBL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + KEY_PAYMENTTBL_BADGETID + " INTEGER NOT NULL, " + KEY_PAYMENTTBL_OUTDATE + " TEXT NOT NULL, " + KEY_PAYMENTTBL_MONEY + " INTEGER NOT NULL, " + KEY_PAYMENTTBL_NOTE + " TEXT);"; db.execSQL(strCreateTbl); } ......

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

旧约Alatus

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值