Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <fstream>
- using namespace std;
- int main()
- {
- ifstream file;
- double checkingBalance, savingsBalance, amount;
- int menu;
- char choice;
- file.open("C:\\Users\\Michael\\Desktop\\college stuff\\CS Labs\\Lab5.txt"); //file path on my laptop
- //file.open("S:\\mackay\\121-51\\Lab5data.txt"); file path at school
- file >> savingsBalance >> checkingBalance;
- file.close();
- cout << "Please choose one of the following options: " << endl << endl;
- cout << setw(4) << " " << "1: Deposit" << endl;
- cout << setw(4) << " " << "2: Withdraw" << endl;
- cout << setw(4) << " " << "3: Balance Inquiry" << endl;
- cout << setw(4) << " " << "4: Transfer Money" << endl;
- cin >> menu;
- if (menu == 1)
- {
- cout << "Checking (C) or Savings (S)? ";
- cin >> choice;
- cout << "How much are you depositing? ";
- cin >> amount;
- if (amount < 0)
- cout << "input invalid";
- else if (choice == 'C')
- {
- cout << "Your old balance was $" << checkingBalance;
- checkingBalance = checkingBalance + amount;
- cout << " and your new balance is $" << checkingBalance << endl;
- }
- else
- {
- cout << "Your old balance was $" << savingsBalance;
- savingsBalance = savingsBalance + amount;
- cout << " and your new balance is $" << savingsBalance << endl;
- }
- }
- else if (menu == 2)
- {
- cout << "Checking (C) or Savings (S)? ";
- cin >> choice;
- cout << "How much are you withdrawing? ";
- cin >> amount;
- if (choice == 'C')
- {
- if (amount < 0 || amount > checkingBalance)
- cout << "input invalid";
- else
- {
- cout << "Your old balance was $" << checkingBalance;
- checkingBalance = checkingBalance - amount;
- cout << " and your new balance is $" << checkingBalance;
- }
- }
- else
- {
- if (amount < 0 || amount > savingsBalance)
- cout << "input invalid";
- else
- {
- cout << "Your old balance was $" << savingsBalance;
- savingsBalance = savingsBalance - amount;
- cout << " and your new balance is $" << savingsBalance;
- }
- }
- }
- else if (menu == 3)
- {
- cout << "Which account, checking (C) or savings (S)? ";
- cin >> choice;
- if (choice == 'C')
- cout << "Your balance is $" << checkingBalance;
- else
- cout << "Your Balance is $" << savingsBalance;
- }
- else if (menu == 4)
- {
- cout << "(C) Checking to Savings? or" << endl << "(S) Savings to Checkings? ";
- cin >> choice;
- cout << "How much to transfer? ";
- cin >> amount;
- if (choice == 'C')
- {
- if (amount < 0 || amount > checkingBalance)
- cout << "invalid input";
- else
- {
- cout << "old balance for checking: $" << checkingBalance << endl;
- cout << "old balance for savings: $" << savingsBalance << endl;
- checkingBalance = checkingBalance - amount;
- savingsBalance = savingsBalance + amount;
- cout << "new balance for checking: $" << checkingBalance << endl;
- cout << "new balance for savings: $" << savingsBalance << endl;
- }
- }
- else
- {
- if (amount < 0 || amount > savingsBalance)
- cout << "invalid input";
- else
- {
- cout << "old balance for checking: $" << checkingBalance << endl;
- cout << "old balance for savings: $" << savingsBalance << endl;
- checkingBalance = checkingBalance + amount;
- savingsBalance = savingsBalance - amount;
- cout << "new balance for checking: $" << checkingBalance << endl;
- cout << "new balance for savings: $" << savingsBalance << endl;
- }
- }
- }
- else
- cout << "invalid input";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement