I have been working on this for a month and it was due last week, so I really need help. My friend has given up on me so I don't know what to do... I'm so lost so if anyone could help me! that would be great...
I need someone to look it over.. I have no clue how to post the coding up on this thing .. so please help!!!
#include<iostream>
#include<string> // library to hold information
#include<ctime> // library to handle math
usingnamespace std;
// Prototype
float investment(); // if the user picks to invest
float borrow(); // if the user picks to borrow
int loop(); // Function to loop the entire banking
int main()
{
string userName; // user's name
string answer; // user's decision to invest or borrow
char i; // user wants to invest
char b; // user wants to borrow
float money; // how much money the user is wanting to borrow or invest into the bank
int interest; // Annual interest rate
int Return; // money being returned
float amount; // how much money being returned
float goal; // investment goal
char loop; // the user decides to loop
int y; // user picks to loop
int n; // user closes the bank
char repeat; // indicates to repeat
repeat = y; // Looping wil occuring when user picks 'y'
cout << "~***~~***~~***~[: Welcome to the Kwantlen Bank :]~***~~***~~***~ " << endl;
cout << "What would you like to put your bank account under: ";
cin >> userName;
cout << "Hello " << userName << ", Do you wan to invest (i) with us or borrow (b) from us? ";
cin >> answer;
loop = int loop()
system("pause");
return 0;
}
// Definition
int loop()
// Purpose: loop banking if the user wants to
// Parameters: Borrowing + investment
// Returns: Main
{
char loop; // the user decides to loop
string y; // user picks to loop
string n; // user closes the bank
char i; // user wants to invest
char repeat; // indicates to repeat
string answer; // user's answer
repeat = y; // Looping wil occuring when user picks 'y'
answer == int y || int n; // answer equals yes or no
{
if(answer == 'i') // user decides to invest
{
i = float investment() // Function: when user wants to invest
}
elseif (answer == b)
{
b = float borrow() // Function: when user wants to borrow
}
} while (repeat == y) // closes the do... while
cout >> "Do another investment/loan calculation (y/n)? ";
cin << repeat;
}
float investment()
// Purpose: To do all investments without crowding the main
// Parameters: Only investment
// Returns: Main
{
char i; // user wants to invest
float money; // how much money the user is wanting to borrow or invest into the bank
int interest; // Annual interest rate
float goal; // investment goal
cout << "Enter the amount to invest annually: ";
cin >> money;
cout << endl;
cout << "Enter the yearly percentage rate of return: "";
cin >> interest;
cout << endl;
cout << "Enter the investment goal: ";
cin >> goal;
cout << endl;
cout << " Year Balance Balance " << endl;
cout << " (Jan. 1) (Dec. 31) " << endl;
cout << "";
}
float borrow()
// Purpose: To do all borrowing without crowding the main
// Parameters: Only investment
// Returns: Main
{
char b; // user wants to borrow
float money; // how much money the user is wanting to borrow or invest into the bank
int Return; // money being returned
float amount; // how much money being returned
cout << "Enter the amount to loan: ";
cin >> money;
cout << endl;
cout << "Enter the annual payment amount: ";
cin >> Return;
cout << endl;
cout << "Enter the investment goal: ";
cin >> amount;
cout << endl;
cout << " Year Balance Balance " << endl;
cout << " (Jan. 1) (Dec. 31) " << endl;
cout << "" ;
}
"You are to write a program that will do two things for the user: it will help them to evaluate how long it will take to achieve a certain investment goal given an annual investment amount and an annual rate of return; also, it will help them to evaluate how long it will take to pay off a loan given a principal amount, an annual payment amount and an annual interest rate. When the user runs the program, the program should ask which one of these procedures the user wants to perform, and then do that procedure. If the user wants to do another set of calculations (for example: for a loan instead of an investment, or for a loan followed by another loan), they will have the option of doing another set of calculations."
For repeating a calculation multiple times you could try something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
do
{
// ....perform some sort of calculation....
// ....
// ....
char repeat;
cout << "would you like to repeat? (y/n)";
cin >> repeat;
while((repeat != 'y') && (repeat != 'Y') && (repeat != 'n') && (repeat != 'N'))
{
cout << "Invalid input. would you like to repeat? (y/n)";
cin >> repeat;
}
}while((ans == 'y') || (ans == 'Y'))
;
The do-while loop will execute the body at least once and then it may execute it several more times depending on if the argument inside "while" is true. I think you should think about starting the code over again and this time test the code whenever you get a little bit done. So first I would write a code making sure the program allows you to perform the calculation multiple times, then I would add the code that lets you calculate the investment and make sure THAT works and finally I would include the code that does the calculation for the loan. This may sound time consuming but I think it'll save you more time in the end.
you should learn the basics of c++ first, i see you have syntax errors...
like this:
loop = int loop()
you should write it like this:
1 2 3 4 5 6 7 8 9 10 11 12
//declare it first
//and don't forget the semicolon
int loop();
//as far as i know, you can't use the same name with function
int loop_one;
//don't forget to define you loop() function
loop_one = loop();
//you can declare it like this too:
//int loop_one = loop();