Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Christian Ballard
- //COSC 1330 - 003
- //This program will set a menu for a bank.
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main()
- {
- cout << "Welcome to Drew's Bank!" << endl;
- cout << endl;
- //Variables
- float balance = 0.0;
- char response = ' ';
- const int NSF = 35;
- float checkValue = 0.0;
- float deposit = 0.0;
- float chargeValue = 0.0;
- char loopQuestion = ' ';
- int checkCount = 0;
- int depositCount = 0;
- int chargeCount = 0;
- float totalCheck = 0.0; //Tracks how much is spent after each transaction
- float totalDeposit = 0.0;//does the same thing here
- float totalCharge = 0.0;//and here
- //find out the users balace
- cout << "What is your current balance? $";
- cin >> balance;
- //Clear the screen
- system("CLS");
- //loopies
- do
- {
- //Bank menu
- cout << "What would you like to do?" << endl;
- cout << endl;
- cout << "For a check, please enter the number '1'" << endl << "For a deposit, please enter the number '2'" << endl << "For a charge, please enter the number '3'" << endl << "To exit, please enter the number '4'" << endl;
- cin >> response;
- system("CLS");
- //Switch statement
- switch (response)
- {
- case '1': //The check option
- cout << "You have chosen the check option." << endl;
- cout << "Your current balance is $" << balance << endl << endl;
- cout << "What is the value of the check?" << endl << "$";
- cin >> checkValue;
- system("CLS");
- // selection
- if (checkValue <= balance)
- {
- balance = balance - checkValue;
- cout << "You have withdrawn $" << checkValue << endl << "Your new balance is $" << balance << endl;
- checkCount++;
- totalCheck = checkValue + totalCheck;
- }
- else
- {
- cout << "You have insufficient funds, an NSF charge of $35.00 has been added to your account." << endl;
- balance = balance - NSF;
- cout << "Your new balance is $" << balance << endl;
- }
- break;
- case '2': //The deposit option
- cout << "You have chosen to make a deposit." << endl;
- cout << "Your current balance is $" << balance << endl << endl;
- cout << "How much would you like to deposit?" << endl << "$";
- cin >> deposit;
- balance = deposit + balance;
- cout << "Your new current balance is." << endl << "$" << balance << endl;
- depositCount++;
- totalDeposit = deposit + totalDeposit;
- break;
- case '3': //The charge option
- cout << "You have chosen to make a charge on your account." << endl;
- cout << "Your current balance is $" << balance << endl << endl;
- cout << endl << "What is the value of the charge?" << endl << "$";
- cin >> chargeValue;
- if (chargeValue > balance)
- {
- cout << "Insufficient funds, card denied." << endl;
- }
- else
- {
- balance = balance - chargeValue;
- cout << "Your new current balance is" << endl << "$" << balance << endl;
- chargeCount++;
- totalCharge = chargeValue + totalCharge;
- }
- break;
- case '4': //The exit option
- cout << "Thank you for exiting the bank." << endl;
- break;
- default: //What happens if the wrong value is entered.
- response = 'z';
- }
- if (response == 'z')
- {
- cout << "Please enter '1' for a check, '2' for a deposit, or '3' for a charge. " << endl;
- }
- {
- cout << "Would you like to make another transaction? (Y/N) " << endl;
- cin >> loopQuestion;
- }
- system("cls");
- } while (toupper(loopQuestion) == 'Y');
- cout << "Thank you for exiting the bank." << endl << endl;
- cout << "Balance $" << setw(5) << balance << endl;
- cout << "Number of checks $" << setw(3) << checkCount << endl;
- cout << "Number of deposits $" << setw(3) << depositCount << endl;
- cout << "Number of charges $" << setw(3) << chargeCount << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement