//Term Project #1 - 100 points
//SOFTWARE FOR A BANK
//Write a C++ program for the following task using modular approach.
//a) Should allow 5 users with user name & password :
//[ (Ohlone1, Ohlone1pw), (Ohlone2, Ohlone2pw),( Ohlone3, Ohlone3pw), (Ohlone4, Ohlone4pw), (Ohlone5, Ohlone5pw)]
//b) Display a welcome / greeting .
//c) Menu driven program to allow:
//‘View Balance’,
//‘Deposit’,
//‘Withdraw’,
//‘Transfer’
//and ‘Exit’.
//Start with a beginning balance of 1000.00 in checking and 1500.00 in savings.
#include <iostream.h>
#include <string.h>
//PROTOTYPE;
void Signin();
void Menu1();
void ViewBalance1();
void Ohlone1_balance();
void Ohlone1_Deposit();
void Ohlone1_Withdraw();
void Ohlone1_Transfer();
void Ohlone1_Checking();
void Ohlone1_Saving();
void main (void)
{
cout << "WELCOME TO PROGRAMMING BANK!\n\n";
cout << "~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~\n\n";
Signin ();
Menu1 ();
}
void Signin ()
{
char username[31], PW[20];
cout << "Please enter your username: \n";
cin.width(32);
cin >> username;
do
{
//User 1
if (strcmp(username, "Ohlone1") ==0)
{
cout << "Please enter your password: \n";
cin >> PW;
for (int i = 0; i < PW; i++)
{
cout << "*"; //How come this technique deosn't work?
}
if (strcmp(PW, "Ohlone1pw") == 0)
cout << "\n\n\tYou are logged in!\n\t";
else
{
cout << "Your password was entered incorrectly.\n";
cout << "Please enter your password again.\n";
cin >> PW;
if (strcmp(PW, "Ohlone1pw") == 0)
cout << "\n\n\tYou are logged in!\n\n";
else
{
cout << "I'm sorry you're having trouble.\n";
break;
}
}
return;
}
//User 2
else if (strcmp(username, "Ohlone2") ==0)
{
cout << "Please enter your password: \n";
cin >> PW;
if (strcmp(PW, "Ohlone2pw") == 0)
cout << "\n\n\tYou are logged in!\n\n";
else
{
cout << "Your password was entered incorrectly.\n";
cout << "Please enter your password again.\n";
cin >> PW;
if (strcmp(PW, "Ohlone2pw") == 0)
cout << "\n\n\tYou are logged in!\n\n";
else
{
cout << "I'm sorry you're having trouble.\n";
break;
}
}
return;
}
//User 3
else if (strcmp(username, "Ohlone3") == 0)
{
cout << "Please enter your password: \n";
cin >> PW;
if (strcmp(PW, "Ohlone3pw") == 0)
cout << "\n\n\tYou are logged in!\n\n";
else
{
cout << "Your password was entered incorrectly.\n";
cout << "Please enter your password again.\n";
cin >> PW;
if (strcmp(PW, "Ohlone3pw") == 0)
cout << "\n\n\tYou are logged in!\n\n";
else
{
cout << "I'm sorry you're having trouble.\n";
break;
}
}
return;
}
//User 4
else if (strcmp(username, "Ohlone4") == 0)
{
cout << "Please enter your password: \n";
cin >> PW;
if (strcmp(PW, "Ohlone4pw") == 0)
cout << "\n\n\tYou are logged in!\n\n";
else
{
cout << "Your password was entered incorrectly.\n";
cout << "Please enter your password again.\n";
cin >> PW;
if (strcmp(PW, "Ohlone4pw") == 0)
cout << "\n\n\tYou are logged in!\n";
else
{
cout << "I'm sorry you're having trouble.\n";
break;
}
}
return;
}
//User 5
else if (strcmp(username, "Ohlone5") == 0)
{
cout << "Please enter your password: \n";
cin >> PW;
if (strcmp(PW, "Ohlone5pw") == 0)
cout << "\n\n\tYou are logged in!\n\n";
else
{
cout << "Your password was entered incorrectly.\n";
cout << "Please enter your password again.\n";
cin >> PW;
if (strcmp(PW, "Ohlone5pw") == 0)
cout << "\n\n\tYou are logged in!\n\n";
else
{
cout << "I'm sorry you're having trouble.\n";
break;
}
}
return;
}
}while (strcmp(username, "Ohlone1") == 0 || (username, "Ohlone2") == 0 ||
(username, "Ohlone3") == 0 || (username, "Ohlone4") ==0 || (username, "Ohlone5") == 0);
if (strcmp(username, "Ohlone1") != 0 || (username, "Ohlone2") != 0 ||
(username, "Ohlone3") != 0 || (username, "Ohlone4") !=0 || (username, "Ohlone5") != 0)
{
cout << "your enter your username incorrectly.\n";
cout << "Please try again.\n";
}
return;
}
void Menu1 ()
{
int choice;
cout << "\nWHAT WOULD YOU LIKE TO DO?\n";
cout << "\n*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n\n";
cout << "\t1. View Your Balance.\n";
cout << "\t2. Deposit.\n";
cout << "\t3. Withdraw.\n";
cout << "\t4. Transfer.\n";
cout << "\t5. Exit.\n\n";
cout << "Please enter your choice: \n";
cin >> choice;
if (choice ==1)
{
Ohlone1_balance();
}
else if (choice ==2)
{
Ohlone1_Deposit();
}
else if (choice ==3)
{
Ohlone1_Withdraw();
}
else if (choice ==4)
{
Ohlone1_Transfer();
}
else if (choice ==5)
{
cout << "You have chosen to exit the menu.\n";
cout << "Thank you for visiting Programming Bank.\n";
return;
}
}
void Ohlone1_balance ()
{
//cout << "Your checking account has : " << << endl;
//cout << "Your saving account has : " << << endl;
}
void Ohlone1_Checking (float *amount)
{
//amount = 1000;
}
void Ohlone1_Saving (float *amount)
{
//amount = 1500;
}
void Ohlone1_Deposit ()
{
int input;
float deposit;
cout << "Which account would you like to deposit to?\n";
cout << "1. Checking Account\n";
cout << "2. Saving Account\n";
cin >> input;
if (input = 1)
{
cout << "How much do you want to deposit to the Checking Account?\n";
cin >> deposit;
}
if (input =2)
{
cout << "How much do you want to deposit to the Saving Account?\n";
cin >> deposit;
}
}
void Ohlone1_Transfer ()
{
int input;
cout << "Would you like to transfer..\n\n";
cout << "1. From CHECKING to SAVING\n";
cout << "\nOR\n\n";
cout << "2. From SAVING to CHECKING\n";
cin >> input;
if (input = 1)
{
// C_to_S ();
}
if (input = 2)
{
// S_to_C ();
}
}
void Ohlone1_Withdraw ()
{
int input;
float withdraw;
cout << "From which account would you like to withdraw?\n";
cout << "1. Checking\n";
cout << "2. Saving\n";
cin >> input;
if (input = 1)
{
cout << "How much would you like to withdraw from the Checking account?\n";
cin >> withdraw;
//what to do here?
}
if (input = 2)
{
cout << "How much would you like to withdraw from the Saving account?\n";
cin >> withdraw;
//what to do here?
}
}