Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- //Banking System
- float debt = 0;
- float bankMoney = 0;
- float interest = 5.00; // Note: Please replace this with a randomizer percentage between 5 to 10.8 percent. Thanks.
- float interest2 = 3.00; // NOte: Please put a randomizer range between 2 - 3%. Thanks
- float loan1 = 0;
- float loan2 = 0; //loan2 = 0 once the user has successfully traded.
- float lastDeposit = 0;
- float lastDeposit2 = 0;
- //Remember Bank
- int memBank = 0;
- int memLoan = 0;
- int memDp = -1;
- int memDp2 = 0;
- int memDebt = 0;
- //The Bank Function
- void theBank(void);
- void rules(void);
- // User Debt Function
- void userDebt(void);
- // Withdraw Function
- void withdraw(void);
- // Deposit Function
- void deposit(void);
- void reports(void);
- // Loan Function
- void loan(void);
- void repay(void);
- void borrow(void);
- void trust(void);
- void trusted(void);
- void checkDebt(void);
- // Compounding Bank Money Function
- void compoundBank(void);
- //The Bank Function
- void theBank(void){
- string input;
- memBank = 0;
- balance_balance();
- cout << endl;
- for (int i = 0; i > 15; i++){
- cout << " ";
- }
- cout << endl;
- cout << "Welcome to Jasper's Bank!";
- cout << endl;
- for (int i = 0; i > 15; i++){
- cout << " ";
- }
- cout << endl;
- cout << "What do you wish to do?";
- cout << endl;
- cout << setw(17);
- cout << "[1] " << setw(15) << "Withdraw";
- cout << endl;
- cout << setw(17);
- cout << "[2] " << setw(15) << "Deposit";
- cout << endl;
- cout << setw(17);
- cout << "[3] " << setw(15) << "Loan"
- cout << endl;
- cout << setw(17);
- cout << "[4] " << setw(15) << "Check Debt";
- cout << endl;
- cout << setw(17);
- cout << "[5] " << setw(15) << "Deposit Report";
- cout << endl;
- cout << setw(17);
- cout << "[6] " << setw(15) << "Rules";
- cout << endl;
- cout << setw(17);
- cout << "[7] " << setw(15) << "Return";
- cout << endl;
- cout << setw(27);
- cout << "Enter Input: ";
- cin >> input;
- if (input == "1"){
- withdraw();
- }
- else if (input == "2"){
- deposit();
- }
- else if (input == "3"){
- loan();
- }
- else if (input == "4"){
- checkDebt();
- }
- else if (input == "5"){
- rules();
- }
- else if (input == "6"){
- reports();
- }
- else if (input == "7"){
- loc();
- }
- else theBank();
- }
- // User Debt Function
- void userDebt(void){
- turnl
- }
- // Withdraw Function
- void withdraw(void){
- balance_balance();
- cout << endl;
- cout << "How much money do you wish to withdraw?";
- cout << endl;
- cout << "Enter Input: Eur ";
- cin >> wd;
- if (wd < 0){
- cout << endl;
- cout << "Invalid input. Please try again!";
- cout << endl;
- system("pause");
- withdraw();
- }
- else if (wd > bankMoney){
- if (memDp2 == 1){
- cout << endl;
- cout << "You've just recently deposited Eur " << bankMoney2 << ".";
- cout << endl;
- cout << "Please wait for another turn . . . ";
- cout << endl;
- theBank();
- }
- cout << endl;
- cout << "You do not have that amount in your bank account . . . ";
- cout << endl;
- system("pause");
- withdraw();
- }
- else if (wd <= bankMoney){
- if (memDp2 == 1){
- cout << endl;
- cout << "You've just recently deposited Eur " << bankMoney2 << ".";
- cout << endl;
- cout << "Please wait for another turn . . . ";
- cout << endl;
- theBank();
- }
- cout << endl;
- cout << "You withdrew Eur " << wd << " to your balance . . . ";
- cout << end;
- cout << "Your balance has been updated . . . "
- balance += wd;
- bankMoney -= wd;
- if (bankMoney == 0){
- memDp = 0;
- }
- system("pause");
- theBank();
- }
- }
- // Deposit Function
- void deposit(void){
- balance_balance();
- float dp;
- float interest;
- cout << endl;
- cout << "How much money do you wish to deposit?";
- cout << "Compound Interest: " << interest << "%"; // Note: Please replace this with a randomizer percentage between 5 to 10.8 percent. Thanks.
- cout << endl;
- cout << "Enter Input: Eur ";
- cin >> dp;
- if (dp < 0){
- cout << endl;
- cout << "Invalid input. Please try again . . . ";
- cout << endl;
- system("pause");
- deposit();
- }
- else if (dp > balance){
- cout << endl;
- cout << "You do not have that amount of money in your balance . . . ";
- cout << endl;
- system("pause");
- deposit();
- }
- else if (dp <= balance){
- cout << endl;
- cout << "You deposited Eur " << dp << " to your bank account . . . ";
- cout << endl;
- cout << "Your balance has been updated . . . ";
- cout << endl;
- if (memDp2 == 0){
- lastDeposit2 = balance;
- }
- memDp = 1;
- memDp2 = 1;
- balance -= dp;
- bankMoney += dp;
- system("pause");
- theBank();
- }
- }
- // Loan Function
- void loan(void){
- memBank = 1;
- string input;
- balance_balance();
- cout << endl;
- cout << "You chose loan . . . ";
- cout << endl;
- cout << "What do you wish to do?"
- cout << endl;
- cout << "[1] Repay";
- cout << endl;
- cout << "[2] Borrow";
- cout << endl;
- cout << "[3] Check Debt";
- cout << endl;
- cout << "[4] Return";
- cout << endl;
- cout << "Enter Input: Eur ";
- cin >> input;
- if (input == "1"){
- repay();
- }
- else if (input == "2"){
- if (loan1 > 0){
- cout << endl;
- cout << "You already have a loan. Please repay your debt . . . ";
- cout << endl;
- cout << "Debt: Eur " << loan1;
- cout << endl;
- loan();
- }
- else borrow();
- }
- else if (input == "3"){
- checkDebt();
- }
- else if (input == "4"){
- theBank();
- }
- else{
- cout << endl;
- cout << "Invalid input. Please try again.";
- cout << endl;
- system("pause");
- loan();
- }
- }
- // Repay
- void repay(){
- balance_balance();
- float repay2 = 0;
- cout << endl;
- cout << "How much money do you want to repay?";
- cout << endl;
- cout << "Enter Input: Eur ";
- cin >> repay2;
- if (loan2 > 0){
- if (repay2 < 0){
- cout << endl;
- cout << "Invalid input. Please try again.";
- cout << endl;
- system("pause");
- }
- else if (repay2 >= loan1){
- cout << endl;
- cout << "You paid the loan too early. " << interest2 << "% repayment penalty.";
- repay2 *= interest2/100;
- loan1 -= repay2;
- loan2 = loan1;
- balance -= repay2
- cout << endl;
- }
- }
- else if (repay2 < 0){
- cout << endl;
- cout << "Invalid input. Please try again.";
- cout << endl;
- system("pause");
- repay();
- }
- else if (repay2 > loan1){
- cout << endl;
- cout << "You cannot repay more than what you owe . . . ";
- cout << endl;
- system("pause");
- repay();
- }
- else if (repay2 <= loan1){
- cout << endl;
- cout << "You have chosen to repay Eur " << loan1 << " by " << repay2 << ".";
- cout << endl;
- loan1 -= repay2;
- balance -= repay2;
- system("pause");
- loan();
- }
- }
- // Borrow
- void borrow(){
- balance_balance();
- float borrow2 = 0;
- cout << endl;
- cout << "How much money do you want to borrow?";
- cout << endl;
- cout << "Enter Input: Eur ";
- cin >> borrow2;
- if (borrow2 < 0){
- cout << endl;
- cout << "Invalid input. Please try again.";
- cout << endl;
- system("pause");
- }
- if (borrow2 <= 1100000){
- //Eur 5000
- if (balance < 5000){
- if (borrow2 > 20000){
- cout << endl;
- trust(); cout << "20000."
- cout << endl;
- cout << endl;
- system("pause");
- }
- else{
- trusted();
- }
- }
- //Eur 10000
- else if (balance < 10000){
- if (borrow2 > 40000){
- cout << endl;
- trust(); cout << "40,000.";
- cout << endl;
- }
- else{
- trusted();
- }
- }
- else if (balance < 20000){
- if (borrow2 > 120000){
- cout << endl;
- trust(); cout << "120,000.";
- cout << endl;
- }
- else{
- trusted();
- }
- }
- else if (balance < 120000){
- if (borrow2 > 400000){
- cout << endl;
- trust(); cout << "400,000.";
- cout << endl;
- }
- else{
- trusted();
- }
- }
- else if (balance < 400000){
- if (borrow2 > 1100000){
- cout << endl;
- cout << "Jasper's Bank is only allowed to loan 15% of its legal capital . . . "
- cout << endl;
- cout << "Please choose a value that is less than or equal to Eur 1,100,000";
- cout << endl;
- borrow();
- }
- else{
- trusted();
- }
- }
- }
- }
- void compoundBank(void){
- float A, P, r, n, t;
- /*
- A - Final Amount
- P - Initial Principal Balance
- r - Interest Rate
- n - Number of Times Interest Applied per Turn Period
- t - Number of 4-Turns
- 1 turn = 4 months
- 3 turns = 12 months
- */
- r = interest2;
- t = memLoan%3;
- n = 1;
- P = bankMoney;
- A = P(pow(1 + (r / n)), n * t);
- bankMoney += A;
- }
- void trust(void){
- cout << endl;
- cout << "Jasper's Bank doesn't trust you to repay your loan."
- cout << endl;
- cout << "Please input a value less than or equal to Eur ";
- }
- void trusted(void){
- cout << endl;
- cout << "You borrowed Eur " << borrow2 << " from Jasper's Bank with " << interest << "%.";
- loan1 += borrow2;
- balance += borrow2;
- loan2 = loan1;
- cout << endl;
- system("pause");
- memLoan = 1;
- loan();
- }
- void checkDebt(void){
- cout << endl;
- cout << "Debt: Eur " << loan1;
- cout << endl;
- system("pause");
- if (memBank == 0){
- theBank();
- }
- else if (memBank == 1){
- loan();
- }
- }
- void rules(void){
- cout << endl;
- cout << endl;
- cout << "Rules"
- cout << endl;
- cout << "============================================================================";
- cout << endl;
- cout << "Every turn is equal to four month.";
- cout << endl;
- cout << "Every three turns is equal to one year.";
- cout << endl;
- cout << "Every turn your loan debt increases.";
- cout << endl;
- cout << "If you have not paid in the third turn your debt will be dealt with taxes.";
- cout << endl;
- cout << "There is a penalty for not paying your debt.";
- cout << endl;
- cout << "============================================================================";
- cout << endl;
- cout << endl;
- }
- void reports(void){
- if (memDp == -1){
- cout << endl;
- cout << "You have not deposited any money yet.";
- cout << endl;
- }
- else if (memDp == 0){
- cout << endl;
- cout << endl;
- cout << "********** Financial Report **********";
- cout << endl;
- cout << "********** Jasper's Bank ***********";
- cout << endl;
- cout << "Last Deposit: Eur " << lastDeposit;
- cout << endl;
- cout << "Increased by: " << (lastDeposit1 / lastDeposit) * 100 << "%.";
- cout << endl;
- cout << "********** End of Report **********";
- cout << endl;
- }
- else if (memDp == 1){
- cout << endl;
- cout << endl;
- cout << "********** Financial Report **********";
- cout << endl;
- cout << "********** Jasper's Bank ***********";
- cout << endl;
- cout << "Curent Deposit: Eur " << lastDeposit
- cout << endl;
- cout << "Increased by: " << (lastDeposit1 / lastDeposit) * 100 << "%.";
- cout << endl;
- cout << "********** End of Report **********";
- cout << endl;
- }
- }
Add Comment
Please, Sign In to add comment