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>
- 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;
- //find out the users balace
- cout << "What is your current balance? " << endl << "$";
- cin >> balance;
- //Clear the screen
- system("CLS");
- //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;
- cin >> response;
- system("CLS");
- //Switch statement
- switch (response)
- {
- case '1':
- cout << "You have chosen the check option." << endl << endl;
- cout << "What is the value of the check?" << endl << "$";
- cin >> checkValue;
- system("CLS");
- if (checkValue <= balance)
- {
- balance = balance - checkValue;
- cout << "You have withdrawn $" << checkValue << endl << "Your new balance is $" << balance << endl;
- }
- 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':
- cout << "You have chosen to make a deposit." << 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;
- break;
- case '3':
- cout << "You have chosen to make a charge on your account." << 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;
- }
- break;
- default:
- response = 'z';
- }
- if (response == 'z')
- {
- cout << "Please enter '1' for a check, '2' for a deposit, or '3' for a charge. " << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment