C++ :: Compound Interest Formula Coding
Sep 24, 2014
Im having problems coding this
A = P(1 + r/n)nt
//Declared test cases
float principal = 200000.00, annualInt = 0.03;
float years = 10.0;
float calcInterest1(float principal, float years, float annualInt) {
float interest1;
float nt = annualInt*12;
float A = principal+annualInt;//Accrued Amount
interest1 = (A = (principal*(1+years/100))pow(nt));// A = P(1 + r/n)nt
return interest1;
}
View 1 Replies
ADVERTISEMENT
Jun 21, 2013
Equation for compound interest. The interest is supposed to be $43.34 according to the book, I am ending up with around $35. The actual equation is amount = principal * (1 + rate/t)^t where t = number of times compounded per year. I still have to go through and clean up all the code I just want the formula working first.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main () {
float princ, rate, comp, savings, interest, rates, year;
[Code] .....
View 2 Replies
View Related
Oct 1, 2013
some where in main:
char value;
char* sname;
sname= new char[20];
for(int i=0;i!=19;i++)
{
cin>>value;
sname[i]=value;
}
I need a stopping case when user press enter array get closed and add '' at the end but how to do that?
View 1 Replies
View Related
Jun 7, 2013
I am making this program for a class and it works fine except for the daily interest rate for the checking account is off. The daily interest for the savings computes perfectly. The monthly interest rate for savings is 6% and for checking 3%.
Account.h
#ifndef ACCOUNT_H
#define ACCOUNT_H
#include <iostream>
#include <string>
using namespace std;
const int DAYS_PER_MONTH = 30;
[Code] ....
View 1 Replies
View Related
Jan 17, 2013
I was trying to make a program of calculating simple intrest using functions. I don't know whats wrong with the program but it always shows a wrong output.
#include<iostream.h>
#include<conio.h>
float si(int p,int r,int t) {
return ((p*t*r)/100.0);
[Code] ....
View 4 Replies
View Related
Feb 11, 2014
math part.
The equation I need to use is: payment = [(rate * (1 + rate)^number payments ) / ((1 + rate)^number of payments -1)] * loan
Also, the value of rate in the above equation is (interest/12)/100. So 12% annual interest would be 1% monthly interest.
heres my code:
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
[Code].....
View 4 Replies
View Related
Mar 23, 2013
I just spent 3 hours writing and debugging 37 lines of code. Is this normal or am I "below average" in coding abilities. I come from a C background and decided to write C++ code that I finally got right as shown below for the specific example:
Code: #include <iostream>
#include <fstream>
#include <string>
#define SPACE_SEARCH 10
using namespace std;
[code].....
I think it was more the learning along the way that consumed atleast 75% of my time for this specific case. But then again, I read that programming always entails learning along the way and so its somehow no excuse for the long time taken in this specific case.
So as a matter of interest, what pace do all of you operate on, on average? i.e. LOC/day, Debugs per day or any other indicator of productivity?
View 3 Replies
View Related
Oct 16, 2013
Is there a way to put a mp3 file into a c program without having the windows media player pop up in the background each time you compile the program? I just wanted to input a few seconds of an audio file..
View 3 Replies
View Related
Sep 27, 2013
Here is my code:
int main (int argc, char* argv[]) {
int x = atoi (argv[1]);
int y = atoi (argv[2]);
int z = atoi (argv[3]);
if (strcmp(argv[4], "Simple") == 0){
[Code ....
I need to convert the output of simple interest to float which is $5184.90 instead of $5180. how to go about it?
View 3 Replies
View Related
Oct 21, 2014
This exercise should familiarise you with loops, if-then-else statements, and recursion. You will have to design and implement a program that calculates the interest earned on a bank-account. Deadline is the end of Tuesday in week 4.
Interests are compounded; that is, you earn interest on interest. Given a yearly interest rate of say, 6%, you can calculate the total sum available when an initial sum of 4000 pounds is put away for 13 years as follows:
4000 * ( (1 + [6/100])^13 ) = 8531.71 pounds
where the caret symbol denotes 'to the power of'. One way to calculate the power is by repeatedly mulitplying. Ie, you can mulitply 1.06 with 1.06 12 times to calculate 1.06^13.
PART 1
Design and implement a function that raises X to the power Y for a real number X and a positive integer Y. The function must use a while loop.
Design and implement a main program that calculates the sum availble when 1000 pounds has been put away for 25 years with 5 percent interest.
Change the while-loop in the function to a for-loop.
View 12 Replies
View Related
Mar 20, 2013
I'm interested in learning how to write the software for audio synthesizers. a friend of mine started on the hardware side for them and, as i have no experience with this type of code.
View 7 Replies
View Related
Apr 30, 2014
Is there any opensource tool which can check the coding style use in a program.
View 2 Replies
View Related
Mar 4, 2014
Write a program that computes how many feet an object falls in 1 second, 2 seconds, etc., up to 12 seconds.
1.Have a procedure called FallingDistance which has one input parameter, seconds, and one output parameter, distance.
2. Compute the distance in feet an object falls using this formula: d = ½ gt2
(where g = 32.2)
3. The main program should call FallingDistance within a loop which passes the values 1 through 12 as arguments.
4. Print a table with seconds and falling distance in feet.
Sample Output (This program has no input)
Seconds Distance
================
1 16.1000
2 64.4000
3 144.9000
4 257.6000
5 402.5000
6 579.6000
7 788.9000
8 1030.4000
9 1304.1000
10 1610
11 1948.1000
12 2318.4000
In C++, the procedure is called a function. Instead of using an output parameter, your C++ function FallingDistance should return a result of type double. This is what I created:
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
const double g =32.2;
double fallingDistance(double);
[Code] ....
which gave me this error:
1>------ Build started: Project: Lab 6, Configuration: Debug Win32 ------
1> Source.cpp
1>c:usershanahdocumentsschoolprogamming ilab 6lab 6source.cpp(27): error C2065: 'fallingdistance' : undeclared identifier
1>c:usershanahdocumentsschoolprogamming ilab 6lab 6source.cpp(36): error C2065: 't' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
View 4 Replies
View Related
Aug 14, 2012
I java We can be able to open any application through coding.. likewise Is it possible to open through c++?
View 3 Replies
View Related
Feb 4, 2013
For each quarter, calculate and display the beginning principal balance, the interest earned, and the final principal balance for the quarter.For example: The user entered 1000.00 for the beginning principal balance, 5.25 for the interest rate, and 8 for the number of quarters. The output from this part of the program should be similar to the following:
Q| Beginning Principle| Interest Earned| End Principle
1| $1,000.00 | $13.13 | $1,013.13
2| $1,013.13 | $13.30 | $1,026.42
3| $1,026.42 | $13.47 | $1,039.89
etc
Here is the code I have so far, and I just am not quite sure where to go next.
Code:
{
cout << "Quarters" << " " << "Beginning Principles" << " " <<"Interest Earned" << " " <<"End Principal" << endl;
endprin = balance + (quarter * interest);
interest = quarter * interest;
cout << endprin << endl;
}
View 2 Replies
View Related
Apr 7, 2014
I have a problem requiring me to :
enter loan amount:
Enter interest rate:
Enter length of loan (years)
It wants me to input the minimum amount for the loan, and the minimum interest rate. and then output a table that has 5 loan amounts across the top in $10000 increments and 4 interest rates along the side in .25% increments.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main () {
double loan, interest, length, payment,ti;
//Enter loan price
[Code] .....
View 1 Replies
View Related
Mar 2, 2013
in order to calculate some logarithm approximation I need to make a variable, say s, search through the whole integer numbers.
Code:
int s;
for {;;s++){
}
[Code] ....
since the variable needs to be initialized right? how to go through all the numbers?
View 3 Replies
View Related
Feb 22, 2013
I am writing a program where all work is done in the class methods. Main is used to call the methods. I need to know how to get a loop to work without any variables in main that can be used outside the methods. This is what I have in main:
#include <iostream>
#include <string>
using namespace std;
#include "FerryBoat.h"
int main() {
//create a constructor for a ferry boat
FerryBoat myBoat('B', 20, 'A');
[Code] ....
View 3 Replies
View Related
Jan 25, 2013
Your objective is to write a program that calculates the simple interest for a given loan amount and duration (in years).
Formula:
Simple interest = loan amount X interest rate X number of years
Assume interest rate is a constant 6% per year.
Specifically, your program will:
1. Output descriptive header
2. Prompt and read any customer’s first name, middle initial, and last name individually
3. Prompt and read the principal/loan amount
4. Prompt and read the duration of the loan in years
5. Calculate the interest
6. Output:
a. Customer full name
b. Principal/loan amount
c. Duration of loan
d. Interest rate
e. Interest on loan
f. Principal and interest due at end of term
OK SO THIS IS MY PROGRAM SO FAR. As you can see i got it all but i am so confused with as to for loan amount and duration of year, if i should use float or double to declare it?
i need to finish this assignment by calculating the simple interest and i dont know how or where to begin.
int main(){
system("color f0");
string firstName;
string middleInitial;
string lastName;
cout<<"Please enter your First Name: ";
[Code]...
View 1 Replies
View Related
Jan 11, 2013
I am trying to create an on-line product store. I'm having trouble with setting up the code to correctly acknowledge quantity desired per product item in the shopping cart at check-out. I want to be able to capture multiple impressions/hits/clicks per item and increase the # in the quantity box each time someone clicks on the same item. For example, if product A is clicked 3 times, then the quantity in the shopping cart should show "3". If it's clicked 5 times, it should show "5" and so on ... However, right now, it's showing the product multiple times in the shopping cart with a quantity of "1" for each time the item was clicked. How can I correct this?
View 2 Replies
View Related
Jan 28, 2014
We are suppose to build a program to do the quadratic formula, which isnt really a issue. my issue is i have a if else loop and my if is being ignored.
what i want it to do is is state that if the (b * /> - 4(a)© is a negative, then it prints out stating it cant do this.
note: i know that i can use the i number system but we have been asked to not too and to do this instead.
here is my code
#include <stdio.h>
#include <math.h>
int main() {
float a, b, c, d, e, f, g, h, i; /* i would love to figure out a way to do this without so many variables*/
[code]....
View 3 Replies
View Related
Mar 21, 2014
I am trying to create a code and cannot get the following part to work :
for (int n = 0; n = timesteps; n++)
{
n = n + 0.1 ;
cout<< "timesteps"<< n << endl ; //print time step value =0.1
for (int j = 0; j < nodesinx; j++)
{
T[j][n+1] = T[j][n] + 0.16 * (T[j][n] - 1[n] - 2[T[j][n] + T[j] + 1[n] ; //equation
n= n + 0.1 ;
cout<< "temperature" << T[j][n+1] << endl;
T[j][n+1] = 0.0 ;
}
}
View 1 Replies
View Related
Jul 27, 2014
It is possible to define the formula of prime numbers in C++ language?
View 1 Replies
View Related
Sep 3, 2013
Its a basic math function using the exponential growth formula which is correct but the computer is not outputting the right numbers.
Code:
#include <stdio.h>
#include <math.h>
int main() {
int blanketsquares, num1, num2, blanket,remainder;
[Code] .....
View 6 Replies
View Related
Nov 7, 2014
I need to calculate the area of a triangle using heron's formula. I wrote the code below and i need to modify it so that a user is required to keep entering the three side until he/she decides to stop. If the three sides entered make an invalid triangle, the user is required to re-enter the values until valid triangle is formed. Then the area is displayed.
#include <iostream>
#include <cmath>
using namespace std;
int main(){
double a,b,c=0;
double s,A=0;
[Code] .....
the screen output should like this:
Enter three sides of a triangle: 0 1 2 Error!
Re-enter three sides of a triangle: -1 1 2 Error!
Re-enter three sides of a triangle: 3 4 5 => 6
Continue (y/n)? y
Enter three sides of a triangle: 1 1 2 Error!
Re-enter three sides of a triangle: 6 8 10 => 24
Continue (y/n)? n
Done!
Please note that Continue (y/n)? only displayed after a valid triangle is formed. Otherwise, the user needs to re-enter sides until it's valid.
View 1 Replies
View Related
Feb 16, 2015
write codes that could solve a quadratic formula, and my codes are like this:
#include <bjarne/std_lib_facilities.h>
int main()
{
cout << "Enter the coefficients of a quadratic polynomial a*x**2 + b*x +c:
";
cout << " a? ";
double a;
cin >> a;
cout << " b? ";
[code]....
Which runs perfectly, but I have 2 questions:
1. How to simplify these code? On the assignment sheet the professor wrote about using void solve_linear(double b, double c); and void solve_ quadratic (double a, double b, double c);which I currently dont understand how these works. He asked us to write a well-encapsulated (as short as possible) program.
2. These are for extra points: the precision problem of floating numbers: professor asked us to find a way to get the precise answer of it, like this: Enter the coefficients of a quadratic polynomial a*x**2 + b*x +c:
a? 1
b? -20000
c? 1.5e-9
Trying to solve the quadratic equation 1*x*x + -20000*x + 1.5e-09 == 0
Using classical formula: Two roots, x = 20000 and x = 0
Using stable formula: Two roots, x = 20000 and x = 7.5e-14
My guess is that
A. Using code like if(x1*x2=a/c) to check if numbers were approximated.
B. Somehow determine the larger one in x1 and x2.
C. Somehow use that larger one to do something
View 2 Replies
View Related