directory structure change, organize by class number as opposed to mod number
Signed-off-by: Amrit Panesar <apanesar@4195tech.com>
This commit is contained in:
1 parent
2a3d6fc042
commit
8683384387
480 files changed
+7
No files matched your search
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "COM203Midterm", "COM203Midterm\COM203Midterm.vcproj", "{4D7EBD5A-8F10-4AD8-A39C-8A1AA836E020}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4D7EBD5A-8F10-4AD8-A39C-8A1AA836E020}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{4D7EBD5A-8F10-4AD8-A39C-8A1AA836E020}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{4D7EBD5A-8F10-4AD8-A39C-8A1AA836E020}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{4D7EBD5A-8F10-4AD8-A39C-8A1AA836E020}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,240 @@
|
||||
/*****************************************************************************
|
||||
* Program: Banking Application Midterm *
|
||||
* Author: Amrit Panesar *
|
||||
* Date: 06/26/2013 *
|
||||
* Course: COM 203 - S. Ganore *
|
||||
* Abstract: A bank account class with methods to deposit, withdraw, *
|
||||
* and check the balance of the account instance *
|
||||
* Depends: Account.h, Standard C Library *
|
||||
* File: Account.h *
|
||||
* Descript: This file contains methods declared in Account.h. This file *
|
||||
* contains the source of the run function as well as the doMenu *
|
||||
* function. The account number and account balanced are randomized*
|
||||
* in the constructor for the Account class. *
|
||||
* For more information see Account.h and main.cpp *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "Account.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::Account(string) - Constructor *
|
||||
* Abstract: The constructor initalizes the accountName with the parameter *
|
||||
* specified. The member variabled accountBalance and accountNum *
|
||||
* are assigned some random value using their respective set procs *
|
||||
******************************************************************************/
|
||||
Account::Account(string namein)
|
||||
{
|
||||
// The constructor initializes the accountName with the parameter specified
|
||||
// The member variables accountBalance and accountNum are assigned some random value
|
||||
setaccountName(namein);
|
||||
unsigned int power = (unsigned int)pow((float)2,31); // pow(2,31) does not compile on visual studio 2008
|
||||
setaccountNumber(rand()%power);
|
||||
setaccountBalance((float)(rand()%power));
|
||||
}
|
||||
/******************************************************************************
|
||||
* Function: Account::~Account() - Destructor *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This destructor prints that it has been called as per the sample *
|
||||
* output provided. *
|
||||
******************************************************************************/
|
||||
Account::~Account()
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
cout << "Destructor Called" << endl;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::setaccountName(string) - Setter *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This sets the accountName member variable. *
|
||||
******************************************************************************/
|
||||
void Account::setaccountName(string namein)
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
accountName = namein;
|
||||
}
|
||||
/******************************************************************************
|
||||
* Function: Account::getaccountName() - Getter *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This gets the accountName member variable. *
|
||||
******************************************************************************/
|
||||
string Account::getaccountName()
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
return accountName;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::setaccountBalance(float) - Setter *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This sets the accountBalance member variable *
|
||||
******************************************************************************/
|
||||
void Account::setaccountBalance(float balancein)
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
accountBalance = balancein;
|
||||
}
|
||||
/******************************************************************************
|
||||
* Function: Account::getaccountBalance() - Getter *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This gets the accountBalance member variable *
|
||||
******************************************************************************/
|
||||
float Account::getaccountBalance()
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
return accountBalance;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::setaccountNumber(float) - Setter *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This sets the accountNumber member variable *
|
||||
******************************************************************************/
|
||||
void Account::setaccountNumber(unsigned int accnumbin)
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
accountNumber = accnumbin;
|
||||
}
|
||||
/******************************************************************************
|
||||
* Function: Account::getaccountNumber(float) - Getter *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This gets the accountNumber member variable *
|
||||
******************************************************************************/
|
||||
unsigned int Account::getaccountNumber()
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
return accountNumber;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::displayAccountInformation() - Display *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This function displays the account balance, number, and name *
|
||||
******************************************************************************/
|
||||
void Account::displayAccountInformation()
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
cout << "Here is the account Information:" << endl;
|
||||
cout << "Account for: " << getaccountName() << endl;
|
||||
cout << "Account #: " << getaccountNumber() << endl;
|
||||
cout << "Balance: $" << getaccountBalance() << endl;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::doExit() - Display *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This function is called at exit and displays a goodbye message *
|
||||
******************************************************************************/
|
||||
void Account::doExit()
|
||||
{
|
||||
cout << "Thank you for using Banking program" << endl;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::withdraw() - Utility *
|
||||
* Abstract: The class will also contain member functions named menu, *
|
||||
* withdraw, and deposit. *
|
||||
* The withdraw function checks to see if balance is sufficient for *
|
||||
* withdrawal. If so, decrements balance by amount; if not, prints *
|
||||
* an appropriate message indicating insufficient funds and displays*
|
||||
* the current balance. *
|
||||
******************************************************************************/
|
||||
void Account::withdraw()
|
||||
{
|
||||
// The class will also contain member functions named menu, withdraw, and deposit
|
||||
float withdraw;
|
||||
cout << "Enter the amount you want to withdraw" << endl << ":";
|
||||
cin >> withdraw;
|
||||
if (withdraw > getaccountBalance())
|
||||
{
|
||||
cout << "ERROR: Cannot withdraw amount due to Insufficient Funds !" << endl;
|
||||
cout << "Your balance remains at: $" << getaccountBalance() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
setaccountBalance(getaccountBalance() - withdraw);
|
||||
cout << "Withdrawing $" << withdraw << " from account #" << getaccountNumber() << endl;;
|
||||
cout << "Your account balance is now: $" << getaccountBalance() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::Deposit() - Utility *
|
||||
* Abstract: The class will also contain member functions named menu, *
|
||||
* withdraw, and deposit. *
|
||||
******************************************************************************/
|
||||
void Account::deposit()
|
||||
{
|
||||
// The class will also contain member functions named menu, withdraw, and deposit
|
||||
float deposit;
|
||||
cout << "Enter the amount you want to deposit" << endl << ":";
|
||||
cin >> deposit;
|
||||
|
||||
setaccountBalance(getaccountBalance() + deposit);
|
||||
cout << "Depositing $" << deposit << " into account #" << getaccountNumber() << endl;
|
||||
cout << "Your account balance is now: $" << getaccountBalance() << endl;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::Menu() - Utility *
|
||||
* Abstract: The class will also contain member functions named menu, *
|
||||
* withdraw, and deposit. *
|
||||
******************************************************************************/
|
||||
void Account::menu()
|
||||
{
|
||||
// The class will also contain member functions named menu, withdraw, and deposit
|
||||
int choice;
|
||||
enum { ACC_BALANCE = 1, DEPOSIT, WITHDRAW, EXIT };
|
||||
while (true)
|
||||
{
|
||||
cout << "*******************************************************************************" << endl;
|
||||
cout << "| Main Menu |" << endl;
|
||||
cout << "*******************************************************************************" << endl;
|
||||
cout << "| 1. Check account balance |" << endl;
|
||||
cout << "| 2. Deposit amount |" << endl;
|
||||
cout << "| 3. Withdraw amount |" << endl;
|
||||
cout << "| 4. Exit |" << endl;
|
||||
cout << "*******************************************************************************" << endl;
|
||||
cout << "Please make a selection" << endl << ":";
|
||||
cin >> choice;
|
||||
|
||||
switch (choice)
|
||||
{
|
||||
case ACC_BALANCE:
|
||||
system("cls");
|
||||
displayAccountInformation();
|
||||
break;
|
||||
case DEPOSIT:
|
||||
system("cls");
|
||||
displayAccountInformation();
|
||||
deposit();
|
||||
break;
|
||||
case WITHDRAW:
|
||||
system("cls");
|
||||
displayAccountInformation();
|
||||
withdraw();
|
||||
break;
|
||||
case EXIT:
|
||||
doExit();
|
||||
break;
|
||||
default:
|
||||
cout << "ERROR: You have made an invalid selection, please chose a different option." << endl;
|
||||
}
|
||||
if (choice == EXIT)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::run() - Utility *
|
||||
* Abstract: Initially calls a function to display the account information, *
|
||||
* then calls the menu function. *
|
||||
******************************************************************************/
|
||||
void Account::run()
|
||||
{
|
||||
system("cls");
|
||||
displayAccountInformation();
|
||||
menu();
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*****************************************************************************
|
||||
* Program: Banking Application Midterm *
|
||||
* Author: Amrit Panesar *
|
||||
* Date: 06/26/2013 *
|
||||
* Course: COM 203 - S. Ganore *
|
||||
* Abstract: A bank account class with methods to deposit, withdraw, *
|
||||
* and check the balance of the account instance *
|
||||
* Depends: Account.h, Standard C Library *
|
||||
* File: Account.h *
|
||||
* Descript: This file contains the function prototypes and declarations *
|
||||
* of data members in use with the banking application midterm. *
|
||||
* Setters and getters for each member variable are provided as *
|
||||
* public members. The constructor for the accont class requires *
|
||||
* a string for the account name. *
|
||||
* For more information see Account.cpp and main.cpp *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <cmath>
|
||||
#include <Windows.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifndef ACCOUNT_H
|
||||
#define ACCOUNT_H
|
||||
|
||||
class Account {
|
||||
private:
|
||||
// Class contains 3 private data members called accountBalance, accountName and accountNum.
|
||||
// Choose appropriate data types for these variables
|
||||
float accountBalance;
|
||||
string accountName;
|
||||
unsigned int accountNumber;
|
||||
|
||||
public:
|
||||
// Write an overloaded constructorthat takes one parameter of the type string.
|
||||
Account(string name);
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
~Account();
|
||||
|
||||
//Write appropriate destructor, set, get and display functions
|
||||
float getaccountBalance();
|
||||
void setaccountBalance(float balance);
|
||||
|
||||
string getaccountName();
|
||||
void setaccountName(string name);
|
||||
|
||||
unsigned int getaccountNumber();
|
||||
void setaccountNumber(unsigned int acccountNumber);
|
||||
|
||||
void displayAccountInformation();
|
||||
|
||||
// The class will also contain member functions named menu, withdraw, and deposit
|
||||
void menu();
|
||||
void withdraw();
|
||||
void deposit();
|
||||
|
||||
void doExit();
|
||||
void run();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,201 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="COM203Midterm"
|
||||
ProjectGUID="{4D7EBD5A-8F10-4AD8-A39C-8A1AA836E020}"
|
||||
RootNamespace="COM203Midterm"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Account.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\main.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Account.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -0,0 +1,46 @@
|
||||
/*****************************************************************************
|
||||
* Program: Banking Application Midterm *
|
||||
* Author: Amrit Panesar *
|
||||
* Date: 06/26/2013 *
|
||||
* Course: COM 203 - S. Ganore *
|
||||
* Abstract: A bank account class with methods to deposit, withdraw, *
|
||||
* and check the balance of the account instance *
|
||||
* Depends: Account.h, Standard C Library *
|
||||
* File: main.cpp *
|
||||
* Descript: This file contains the main method for the Banking application *
|
||||
* it prompts the user for a name, seeds the random function, and *
|
||||
* creates an instance of the Account class. *
|
||||
* For more information see Account.cpp and Account.h *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "Account.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
//even though there is No need to use rand function, I find it easier.
|
||||
srand((unsigned int)time(NULL));
|
||||
|
||||
//some place to store the name
|
||||
string accountName;
|
||||
|
||||
//begin name choosing loop.
|
||||
while (true)
|
||||
{
|
||||
cout << "Welcome to the Bank Account program" << endl;
|
||||
cout << "What is your name?" << endl << ":";
|
||||
cin >> accountName;
|
||||
cout << "Your name is " << accountName << ". Is that correct?" << endl << "[Y/n]:";
|
||||
char choice;
|
||||
cin >> choice;
|
||||
if (toupper(choice) == 'Y') // toupper() because Yes, yes, Y and y will all be converted to Y
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Account acc(accountName);
|
||||
acc.run();
|
||||
|
||||
system("pause"); // a call to Windows.h, makes the pause thingy
|
||||
return 0; //success
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Com203Midterm", "Com203Midterm\Com203Midterm.vcxproj", "{15660994-69D3-4D19-9752-3E9FB1F75092}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{15660994-69D3-4D19-9752-3E9FB1F75092}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{15660994-69D3-4D19-9752-3E9FB1F75092}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{15660994-69D3-4D19-9752-3E9FB1F75092}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{15660994-69D3-4D19-9752-3E9FB1F75092}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,238 @@
|
||||
/*****************************************************************************
|
||||
* Program: Banking Application Midterm *
|
||||
* Author: Amrit Panesar *
|
||||
* Date: 06/26/2013 *
|
||||
* Course: COM 203 - S. Ganore *
|
||||
* Abstract: A bank account class with methods to deposit, withdraw, *
|
||||
* and check the balance of the account instance *
|
||||
* Depends: Account.h, Standard C Library *
|
||||
* File: Account.h *
|
||||
* Descript: This file contains methods declared in Account.h. This file *
|
||||
* contains the source of the run function as well as the doMenu *
|
||||
* function. The account number and account balanced are randomized*
|
||||
* in the constructor for the Account class. *
|
||||
* For more information see Account.h and main.cpp *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "Account.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::Account(string) - Constructor *
|
||||
* Abstract: The constructor initalizes the accountName with the parameter *
|
||||
* specified. The member variabled accountBalance and accountNum *
|
||||
* are assigned some random value using their respective set procs *
|
||||
******************************************************************************/
|
||||
Account::Account(string namein)
|
||||
{
|
||||
// The constructor initializes the accountName with the parameter specified
|
||||
// The member variables accountBalance and accountNum are assigned some random value
|
||||
setaccountName(namein);
|
||||
setaccountNumber(rand()%(unsigned int)pow(2,31));
|
||||
setaccountBalance(rand()%(unsigned int)pow(2,31));
|
||||
}
|
||||
/******************************************************************************
|
||||
* Function: Account::~Account() - Destructor *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This destructor prints that it has been called as per the sample *
|
||||
* output provided. *
|
||||
******************************************************************************/
|
||||
Account::~Account()
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
cout << "Destructor Called" << endl;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::setaccountName(string) - Setter *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This sets the accountName member variable. *
|
||||
******************************************************************************/
|
||||
void Account::setaccountName(string namein)
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
accountName = namein;
|
||||
}
|
||||
/******************************************************************************
|
||||
* Function: Account::getaccountName() - Getter *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This gets the accountName member variable. *
|
||||
******************************************************************************/
|
||||
string Account::getaccountName()
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
return accountName;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::setaccountBalance(float) - Setter *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This sets the accountBalance member variable *
|
||||
******************************************************************************/
|
||||
void Account::setaccountBalance(float balancein)
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
accountBalance = balancein;
|
||||
}
|
||||
/******************************************************************************
|
||||
* Function: Account::getaccountBalance() - Getter *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This gets the accountBalance member variable *
|
||||
******************************************************************************/
|
||||
float Account::getaccountBalance()
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
return accountBalance;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::setaccountNumber(float) - Setter *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This sets the accountNumber member variable *
|
||||
******************************************************************************/
|
||||
void Account::setaccountNumber(unsigned int accnumbin)
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
accountNumber = accnumbin;
|
||||
}
|
||||
/******************************************************************************
|
||||
* Function: Account::getaccountNumber(float) - Getter *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This gets the accountNumber member variable *
|
||||
******************************************************************************/
|
||||
unsigned int Account::getaccountNumber()
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
return accountNumber;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::displayAccountInformation() - Display *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This function displays the account balance, number, and name *
|
||||
******************************************************************************/
|
||||
void Account::displayAccountInformation()
|
||||
{
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
cout << "Here is the account Information:" << endl;
|
||||
cout << "Account for: " << getaccountName() << endl;
|
||||
cout << "Account #: " << getaccountNumber() << endl;
|
||||
cout << "Balance: $" << getaccountBalance() << endl;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::doExit() - Display *
|
||||
* Abstract: Write the appropriate destructor, set and display functions. *
|
||||
* This function is called at exit and displays a goodbye message *
|
||||
******************************************************************************/
|
||||
void Account::doExit()
|
||||
{
|
||||
cout << "Thank you for using Banking program" << endl;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::withdraw() - Utility *
|
||||
* Abstract: The class will also contain member functions named menu, *
|
||||
* withdraw, and deposit. *
|
||||
* The withdraw function checks to see if balance is sufficient for *
|
||||
* withdrawal. If so, decrements balance by amount; if not, prints *
|
||||
* an appropriate message indicating insufficient funds and displays*
|
||||
* the current balance. *
|
||||
******************************************************************************/
|
||||
void Account::withdraw()
|
||||
{
|
||||
// The class will also contain member functions named menu, withdraw, and deposit
|
||||
float withdraw;
|
||||
cout << "Enter the amount you want to withdraw" << endl << ":";
|
||||
cin >> withdraw;
|
||||
if (withdraw > getaccountBalance())
|
||||
{
|
||||
cout << "ERROR: Cannot withdraw amount due to Insufficient Funds !" << endl;
|
||||
cout << "Your balance remains at: $" << getaccountBalance() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
setaccountBalance(getaccountBalance() - withdraw);
|
||||
cout << "Withdrawing $" << withdraw << " from account #" << getaccountNumber() << endl;;
|
||||
cout << "Your account balance is now: $" << getaccountBalance() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::Deposit() - Utility *
|
||||
* Abstract: The class will also contain member functions named menu, *
|
||||
* withdraw, and deposit. *
|
||||
******************************************************************************/
|
||||
void Account::deposit()
|
||||
{
|
||||
// The class will also contain member functions named menu, withdraw, and deposit
|
||||
float deposit;
|
||||
cout << "Enter the amount you want to deposit" << endl << ":";
|
||||
cin >> deposit;
|
||||
|
||||
cout << "Depositing $" << deposit << " into account #" << getaccountNumber() << endl;
|
||||
cout << "Your account balance is now: $" << getaccountBalance() << endl;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::Menu() - Utility *
|
||||
* Abstract: The class will also contain member functions named menu, *
|
||||
* withdraw, and deposit. *
|
||||
******************************************************************************/
|
||||
void Account::menu()
|
||||
{
|
||||
// The class will also contain member functions named menu, withdraw, and deposit
|
||||
int choice;
|
||||
enum { ACC_BALANCE = 1, DEPOSIT, WITHDRAW, EXIT };
|
||||
while (true)
|
||||
{
|
||||
cout << "*******************************************************************************" << endl;
|
||||
cout << "| Main Menu |" << endl;
|
||||
cout << "*******************************************************************************" << endl;
|
||||
cout << "| 1. Check account balance |" << endl;
|
||||
cout << "| 2. Deposit amount |" << endl;
|
||||
cout << "| 3. Withdraw amount |" << endl;
|
||||
cout << "| 4. Exit |" << endl;
|
||||
cout << "*******************************************************************************" << endl;
|
||||
cout << "Please make a selection" << endl << ":";
|
||||
cin >> choice;
|
||||
|
||||
switch (choice)
|
||||
{
|
||||
case ACC_BALANCE:
|
||||
system("cls");
|
||||
displayAccountInformation();
|
||||
break;
|
||||
case DEPOSIT:
|
||||
system("cls");
|
||||
displayAccountInformation();
|
||||
deposit();
|
||||
break;
|
||||
case WITHDRAW:
|
||||
system("cls");
|
||||
displayAccountInformation();
|
||||
withdraw();
|
||||
break;
|
||||
case EXIT:
|
||||
doExit();
|
||||
break;
|
||||
default:
|
||||
cout << "ERROR: You have made an invalid selection, please chose a different option." << endl;
|
||||
}
|
||||
if (choice == EXIT)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function: Account::run() - Utility *
|
||||
* Abstract: Initially calls a function to display the account information, *
|
||||
* then calls the menu function. *
|
||||
******************************************************************************/
|
||||
void Account::run()
|
||||
{
|
||||
system("cls");
|
||||
displayAccountInformation();
|
||||
menu();
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*****************************************************************************
|
||||
* Program: Banking Application Midterm *
|
||||
* Author: Amrit Panesar *
|
||||
* Date: 06/26/2013 *
|
||||
* Course: COM 203 - S. Ganore *
|
||||
* Abstract: A bank account class with methods to deposit, withdraw, *
|
||||
* and check the balance of the account instance *
|
||||
* Depends: Account.h, Standard C Library *
|
||||
* File: Account.h *
|
||||
* Descript: This file contains the function prototypes and declarations *
|
||||
* of data members in use with the banking application midterm. *
|
||||
* Setters and getters for each member variable are provided as *
|
||||
* public members. The constructor for the accont class requires *
|
||||
* a string for the account name. *
|
||||
* For more information see Account.cpp and main.cpp *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <Windows.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifndef ACCOUNT_H
|
||||
#define ACCOUNT_H
|
||||
|
||||
class Account {
|
||||
private:
|
||||
// Class contains 3 private data members called accountBalance, accountName and accountNum.
|
||||
// Choose appropriate data types for these variables
|
||||
float accountBalance;
|
||||
string accountName;
|
||||
unsigned int accountNumber;
|
||||
|
||||
public:
|
||||
// Write an overloaded constructorthat takes one parameter of the type string.
|
||||
Account(string name);
|
||||
// Write appropriate destructor, set, get and display functions
|
||||
~Account();
|
||||
|
||||
//Write appropriate destructor, set, get and display functions
|
||||
float getaccountBalance();
|
||||
void setaccountBalance(float balance);
|
||||
|
||||
string getaccountName();
|
||||
void setaccountName(string name);
|
||||
|
||||
unsigned int getaccountNumber();
|
||||
void setaccountNumber(unsigned int acccountNumber);
|
||||
|
||||
void displayAccountInformation();
|
||||
|
||||
// The class will also contain member functions named menu, withdraw, and deposit
|
||||
void menu();
|
||||
void withdraw();
|
||||
void deposit();
|
||||
|
||||
void doExit();
|
||||
void run();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Account.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Account.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{15660994-69D3-4D19-9752-3E9FB1F75092}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>Com203Midterm</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Account.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Account.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,46 @@
|
||||
/*****************************************************************************
|
||||
* Program: Banking Application Midterm *
|
||||
* Author: Amrit Panesar *
|
||||
* Date: 06/26/2013 *
|
||||
* Course: COM 203 - S. Ganore *
|
||||
* Abstract: A bank account class with methods to deposit, withdraw, *
|
||||
* and check the balance of the account instance *
|
||||
* Depends: Account.h, Standard C Library *
|
||||
* File: main.cpp *
|
||||
* Descript: This file contains the main method for the Banking application *
|
||||
* it prompts the user for a name, seeds the random function, and *
|
||||
* creates an instance of the Account class. *
|
||||
* For more information see Account.cpp and Account.h *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "Account.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
//even though there is No need to use rand function, I find it easier.
|
||||
srand((unsigned int)time(NULL));
|
||||
|
||||
//some place to store the name
|
||||
string accountName;
|
||||
|
||||
//begin name choosing loop.
|
||||
while (true)
|
||||
{
|
||||
cout << "Welcome to the Bank Account program" << endl;
|
||||
cout << "What is your name?" << endl << ":";
|
||||
cin >> accountName;
|
||||
cout << "Your name is " << accountName << ". Is that correct?" << endl << "[Y/n]:";
|
||||
char choice;
|
||||
cin >> choice;
|
||||
if (toupper(choice) == 'Y') // toupper() because Yes, yes, Y and y will all be converted to Y
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Account acc(accountName);
|
||||
acc.run();
|
||||
|
||||
system("pause"); // a call to Windows.h, makes the pause thingy
|
||||
return 0; //success
|
||||
}
|
||||
Reference in new issue
Block a user