⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 个人财政支出管理.txt

📁 个人财政支出管理的关键源程序代码
💻 TXT
字号:
/*第4题	个人财政支出管理--源代码及关键源代码注解如下:*/
/*The Code from web site :www.technocode.scriptmania.com.*/
#include <iostream.h>
#include <fstream.h>
#include <conio.h>
#include <iomanip.h>

void Deposit();
void Withdraw();
void ViewTotal();
void SetGoal();                 //Declaring all my functions
void depositDisplay();
void mainDisplay();
void withdrawDisplay();
void setgoalDisplay();
void viewtotalDisplay();

int main(){
    char select;
        //clrscr(); // if add ?
        mainDisplay();//Title that displays heading with background color.
        cout<<"\n\n\t<1> Deposit"<<endl;
        cout<<"\n\t<2> Withdraw"<<endl;
        cout<<"\n\t<3> View Total"<<endl;
        cout<<"\n\t<4> Set Goal"<<endl;
        cout<<"\n\t<0> Exit"<<endl;
        cout<<"\n\n\tEnter selection: ";
        cin>>select;
        if(select == '1'){Deposit();}else{
        if(select == '2'){Withdraw();}else{
        if(select == '3'){ViewTotal();}else{
        if(select == '4'){SetGoal();}else{
        if(select == '0')
		{
			//exit(1);
			goto mm1;
		}
		else{
        main();
		}
		}}}}
mm1:        return 0;
}

void Deposit(){//Depositing amounts into program
        double dAmt = 0;
        char ans;
        double num = 0;
//Gets any amount that is in the Deposit file to add later on.
        ifstream get("Deposit.txt");
        get>>num;
        get.close();
        depositDisplay();//My splash display screen.
        cout<<"\n\n\tEnter deposit amount: $";
        cin>>dAmt;
//Checks if amount entered is no a negative # or 0 and then continues
        if(dAmt <= 0){
        cout<<"\n\n\n\n\n"<<endl;
        //textcolor(RED); //if add ?
        cprintf("           That was an invalid amount..");
        //textcolor(LIGHTGRAY); //if add ?
        getch();
        main();
        }else{
        cout<<"\n\n\tAmount entered <"<<dAmt<<">."<<endl;
        cout<<"\n\tContinue with deposit <y/n>: ";
        cin>>ans;

        if(ans == 'y' || 'Y'){
        dAmt = dAmt + num;//add amount entered by what was retrieved earlier
        ofstream save("Deposit.txt");
        save<<dAmt<<endl;
        save.close();
        //clrscr();
        cout<<"\n\n\n\n\n"<<endl;
        //textcolor(LIGHTBLUE); //changes color of text //if add ?
        cprintf("             Your deposit was successful...");
        //textcolor(LIGHTGRAY); //if add ?
        getch();
        main();
        }else{
        main();
        }
        main();
        }

}

void Withdraw(){
        double wAmt = 0;
        char ans;
        double num = 0;

        ifstream get("Withdraw.txt");
        get>>num;
        get.close();
        withdrawDisplay();
        cout<<"\n\n\tEnter withdraw amount: $";
        cin>>wAmt;
        if(wAmt <= 0){
        cout<<"\n\n\n\n\n"<<endl;
        //textcolor(RED) //if add ?
        cprintf("           That was an invalid amount..");
        //textcolor(LIGHTGRAY); //if add ?
        getch();
        main();
        }else{
        cout<<"\n\n\tAmount entered <"<<wAmt<<">."<<endl;
        cout<<"\n\tContinue with withdrawal <y/n>: ";
        cin>>ans;

        if(ans == 'y' || 'Y'){
        wAmt = wAmt + num;
        ofstream save("Withdraw.txt");
        save<<wAmt<<endl;
        save.close();
        //clrscr();//if add ?
        cout<<"\n\n\n\n\n"<<endl;
        //textcolor(LIGHTBLUE);//if add ?
        cprintf("             Your withdrawal was successful...");
        //textcolor(LIGHTGRAY);//if add ?
        getch();
        main();
        }else{
        main();
        }
        main();
        }
}

void SetGoal(){
        double setAmt = 0;
        setgoalDisplay();
        cout<<"\n\n\tSet Goal amount: ";
        cin>>setAmt;
        ofstream set("Goal.txt");
        set<<setAmt<<endl;
        set.close();
        //clrscr(); //if add ?
        cout<<"\n\n\n\n\n"<<endl;
        //textcolor(LIGHTBLUE);//if add ?
        cprintf("             Goal amount was set...");
        //textcolor(LIGHTGRAY);//if add ?
        getch();
        main();
}

void ViewTotal(){
        double dAmt = 0;
        double wAmt = 0;
        double gAmt = 0;
        double balance = 0;
        double newbalance = 0;
        ifstream getDeposit("Deposit.txt");
        getDeposit>>dAmt;
        getDeposit.close();
        ifstream getWithdraw("Withdraw.txt");
        getWithdraw>>wAmt;
        getWithdraw.close();
        ifstream getGoal("Goal.txt");
        getGoal>>gAmt;
        getGoal.close();
//Withdrawal amount is minus from Deposit amount and put into balance.
        balance = dAmt - wAmt;
        viewtotalDisplay();
        cout<<"\n\n"<<endl;
        //textcolor(LIGHTBLUE);//if add ?
        cprintf("                          Total Amounts");
        cout<<""<<endl;
        cprintf("                          =============");
        //textcolor(BLUE);//if add ?
        //textbackground(WHITE);//if add ?
        cout<<"\n\n"<<endl;
        cprintf("Deposit Total Withdraw Total  Balance Total ");
        //textbackground(BLACK);//if add ?
        //textcolor(LIGHTGRAY);//if add ?
        cout<<"\n"<<endl;
        cout<<setw(15)<<dAmt<<setw(25)<<wAmt<<setw(20)<<balance<<endl;;
//setw(15) sets the margins between the text.
        newbalance = gAmt - balance;
        cout<<"\n\n\n"<<endl;
        //textcolor(LIGHTBLUE);//if add ?
        cprintf("                          Total Balance");
        cout<<""<<endl;
        cprintf("                          =============");
        //textcolor(BLUE);//if add ?
        //textbackground(WHITE);//if add ?
        cout<<"\n\n"<<endl;
        cprintf("Set Goal Total Balance Total  Balance Left ");
        //textcolor(LIGHTGRAY);
        cout<<"\n"<<endl;
        cout<<setw(15)<<gAmt<<setw(25)<<balance<<setw(23)<<newbalance<<endl;
        //textbackground(BLACK);
        getch();
        main();
}
//================These are all my color displays for my headings===========

void depositDisplay(){

     //clrscr();
     //textbackground(BLUE);
     cprintf("DEPOSIT  ");
     //textbackground(BLACK);
}

void mainDisplay(){

     //clrscr();
     //textbackground(BLUE);
     cprintf("Money Manager   ");
     //textbackground(BLACK);
}

void withdrawDisplay(){

     cprintf("WITHDRAW  ");
}


void setgoalDisplay(){

     cprintf("SET GOAL ");
}


void viewtotalDisplay()
{

     cprintf("VIEW TOTALS ");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -