| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
C++ school assignment
I need some help on this program I am working on :
"Create a program that will prompt the user to enter a monthly interest rate, the amount of a monthly deposit and a target value. Then starting with a zero balance, calculate the number of years and months needed to reach the target with monthly compounding. An Example output follows: (red text indicates user input) *** Financial Planner *** Please enter the monthly interest rate: 2.5 Please enter the monthly deposit amount: $50 Please enter the target value: $50000 Your balance will be $50019.10 after 10 years and 11 months. Notes: The interest rate will have to be adjusted for calculations. Initial balance = 0, after first month add $50 then add 2.5% of the account balance to obtain first month-end balance. Second month, add the month’s $50 deposit and add 2.5% of the account balance to obtain second month-end balance. Continue until target value is reached." __________________________________________________ _____________ I am pretty new to c++ and here is what i have started: #include <iostream.h> int main() { // variables float interest; float deposit; float target; float balance; cout << "Please enter the monthly interest rate:\n"; cin >> interest; cout << "Pease enter the amount of a monthly deposit:\n"; cin >> deposit; cout << "Please enter the target value:\n"; cin >> target; balance=0; while (balance <= target); while (balance += (balance * interest)); while (balance += deposit); { cout <<"Your balance will be " <<balance << " after "; } return 0; } URL |
|
#2
|
||||
|
||||
|
What is the problem exactly? Can you be more specific? Please don't ask for you assignments to be done here.
|
|
#3
|
||||
|
||||
|
Geo
Well I'm only a student as well and I'm not even in my major classes yet but I have read two books on C++ programming. That doesn't mean I know anything though. If your getting a syntax error when you try to compile this, its probably because your putting a .h behind #include <iostream> = I use Visual Studio 2005 beta, Im not sure what your using but when I put the .h behind i get a cannot open error!!!
Let me know if this helps you out!!! Last edited by Geo.Garnett : July 12th, 2005 at 01:06 AM. Reason: Forgot to add what Program I use!! |
|
#4
|
|||
|
|||
|
In addition to dropping .h in #include <iostream.h> you also have to use
using namespace std; e.g. Code:
#include <iostream> using namespace std; If you are wondering why we have to drop .h, well, .h file was the old header, and the one wihtout .h is the latest header file. ----- Programming (Assignment/Project) Help |
|
#5
|
|||
|
|||
|
Quote:
hello you ! i am beginer in C++ .Code is : #include<iostream.h> float Monthly(float interest_rate,float monthy_deposit,float target_value); int main() { cout<<"month is :"<<Monthly(0.25,50,50000); return 0; } float Monthly(float interest_rate,float monthy_deposit,float target_value) { float month=int ();//hoac int month =int () while (monthy_deposit<target_value) { monthy_deposit=(monthy_deposit)+(interest_rate*mon thy_deposit); month++; } return month; } |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > C++ school assignment |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|