Hello princekid,
To start with let me make some observations, hints and suggestions.
I will not go into detail, but
using namespace std;
is not the best idea. I also realize that you may have been told to use this for a reason. Wish I could understand that. You can always do a search here on "using namespace std" and you should find many posts covering the topic.
In "main" you start be defining your variables. Some you have initialized and some you have not. My opinion is to initialize all variables to at least have the piece of mind that none of the variables contain a garbage value. And it is true that some variables do not need initialized like "StartBal" because the next lines get a value for this variable, i.e., it gets a value quickly. Since C++11 standards on initializing a variable is so easy, why not, e.g., "startBal{}". The empty {}s will initialize, in this case the double, to 0.0. For an "int" it would be zero.
Also it is best to start a regular variable with a lower case letter and camelCase is most often used when writing a variable name. So "StartBal" would become "startBal". Starting a name with a capital is generally used with classes and structs. My personal choice is to use a capital to start a function although this is not necessary.
In the section where you enter the "annual interest rate". This is a time to think about the user that is entering the number. Some people will have no idea the "2.25%" is the same as "0.0225" or even how to enter the proper decimal number. I would allow the user to enter "2.25" as a percentage and then divide this by 100 and put the result in "AmtInt" for later use.
Everything inside the for loop appears to be doing its job properly.
In the "display report" section I offer this as what could be done:
1 2 3 4 5 6 7 8 9 10 11
|
// Display report
std::cout << "\n Quarterly Savings Account Report\n";
std::cout << std::setfill('-') << std::setw(34) << '-' << std::setfill(' ') << '\n';
//<< "------------------------------------\n";
std::cout << std::fixed << std::showpoint << std::setprecision(2);
std::cout << std::setw(22) << "Starting balance : $ " << std::setw(9) << StartBal << std::endl;
std::cout << std::setw(22) << "Total deposits : $ " << std::setw(9) << TotDepo << std::endl;
std::cout << std::setw(22) << "Total withdrawals : $ " << std::setw(9) << TotalWd << std::endl;
std::cout << std::setw(22) << "Total interest : $ " << std::setw(9) << TotInt << std::endl;
std::cout << std::setw(22) << "Final balance : $ " << std::setw(9) << MthStart << std::endl;
|
Line 3 is not a requirement, but to show you what could be done.
Lines 7 - 11 the first "setw()" helps to line up the output better. I do this because I am picky and from the experience I have. I think if you give it a test you will like it better.
That said and moving on to the changes.
NOTE: You will get the inputs from a file. You WILL accept negative numbers (indicating withdrawals). |
I would start with this and decide if you want to open the file in "main" or in the function that uses it. Part of this will depend on how you read the file. Either one line at a time or the whole file putting the information into some container for later use. I would help to know what the contents of this file are.
I would work on this first because until you can get information to work with the other functions could be started, but you will have nothing to pass to these functions to work with.
Hope that helps,
Andy