C++ ::  converting Output Of Simple Interest To Float

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


ADVERTISEMENT

C++ :: Simple Input / Output - Float Point Numbers

Apr 26, 2012

I have a simple input output problem using float point numbers and after the first input the program skips the other cin functions is there something that I did wrong? It compiles fine also.

Code:
#include <iostream>
#include <float.h>
using namespace std;
int main() {
int x;
int y;
int z;

[Code] .....

View 5 Replies View Related

C++ :: Calculate Simple Interest Using Functions

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

C++ :: Calculate Simple Interest Of Given Loan Amount And Duration In Years

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

C++ :: Converting String Value Into Float

Feb 21, 2015

In my project i have to take the string valve and convert it into float

For example
100 will be 100.00
100.0012 will be invalid
100.00 will stay as it is
99 will be 99.00

I am thinking of using stof but i m stuck on how to set the precision of 2 ....

View 2 Replies View Related

C/C++ :: Converting From Float To Decimal?

Sep 11, 2014

Question: A computer uses 10 bits to store integers with 1 bit for a sign. It stores an approximation of real numbers in 10 bits. The first bit of the first five is the sign of the mantissa and the other four bits are the mantissa. The first bit of the second five is the sign of the exponent and the other four the exponent.

1)What is the range of integers?

2)what is the range of real numbers(Float Type)

The first question was simple. I just found the smallest 10 digit binary number 1000000000 = -512 and then found the largest 10 digit binary number which would have to be 0111111111 = 511, therefore the range of integers is from -512 to 511.

For the second question - I am either making this harder than it is, or it really is a challenging question. So I followed the steps and first I was thinking I would take the number 1000000000 and convert this to a decimal (assuming its a 10 bit float)...But, can you even do this with a 10 bit float??

I ended up getting 1000000000 (after denormalizing) = .000100000 = 0.625.. would that be the minimum range? If so, then I know what I need to do to find the maximum , but if not - then I am really lost.

My Process was:

1.00000 X 2^(-4) = my final result of 0.625 after converting.

View 9 Replies View Related

C++ :: Converting String Variable To Float

Apr 11, 2014

I would like to convert a string variable to float.When acquiring data from text file, I use:

while( getline( ifs, temp )) {
numberOfFeatures++;
vecteur.clear();
string::size_type stTemp = temp.find(separateur);
number_descriptorEntries=0;

[code].....

the matrix that I obtain is of type vector<Vec> where Vec is a vector of strings.I want to convert each element of matrixe to a float.

View 3 Replies View Related

C++ :: Converting String To Char And Float

Nov 15, 2013

So I have to convert ("a499.9") into a char and a float while ignoring the a.

I have the string stored in a buffer and found how to get the char, 4. But I don't know how to get 99.9 as a float.

Here is my code so far.

#include <string>
using namespace std;
main() {
buffer = "a499.9";

[Code] ....

My output:

4
0

How to get that double out?

View 7 Replies View Related

C++ :: Converting Time String To Float?

Jun 5, 2013

I have a vector<string> of times that I want to convert to vector<double>. The time string is in the form 00:00.000. Is there a STL or something like it algorithm or function to do this, otherwise what would be the best way to do this with a function.

View 3 Replies View Related

Visual C++ :: Converting Float To String?

May 16, 2014

I have an assignment that is due on monday I am stuck on this function. I have to convert my netpay which is a float to a string So if i have 356.26 it should output the sum of three hundred fifty-six and 26/100 dollars my program function works for the sum of three hundred but after that it spits out garbage.

Code:
void convertNetPay(float netPay, char *netPayString) {
int numHuns, numTens, numOnes;
char OnesTable[9][8]={"One","Two","Three","Four","Five","Six","Seven","Eight","Nine"};
char ResultString[10+1];

[code].....

View 3 Replies View Related

C :: Converting Simple Crc32 Program To Octave

May 1, 2014

I have been working on a simple crc32 program in octave and have been using a program already done in C as a guideline. I have been having some problems since octave and C simply do things differently. Right now i have a problem with right shifting.

unsigned int crc = -85
unsigned int x = (crc >> 1);

The resulting x will be 2147483605. I tried putting 0xFFFFFFFF instead of -85 and i got the same result.

If i put -85 for crc in octave, i get a small number -43 which looks more reasonable.

View 1 Replies View Related

C :: Simple Decimal Input To Binary Output

Jun 22, 2013

I am learning c because I want to get back into programming microcontrollers, which I previously did in assembly. I wanted to make something fairly tight in terms of program memory and RAM to show me an output in binary form. When you are troubleshooting a file register or serial interface when you can see the actual bit values (on a small LCD for a micro-controller) and compare it to a datasheet.

Code:
#include <stdio.h>
#include <math.h>
int main() {
int i;
int decimaltoconvert;
int convertingarray[7];
int convertingarray2[7];

[Code] .....

Also, how might I go about putting that into a function that I could call?

View 6 Replies View Related

C++ :: Draw Simple Graphs To Have Visualization Of Output Generated

Mar 21, 2014

I am writing sample programs for graph problems like Dijkstra or Bellman-Ford algorithms. In Dijkstra, for instance, when I input my program a set of vertices and edges, ask to find shortest path from Vertex A to Vertex B, my program currently outputs shortest path from A to B. I want to display graph and have a visualization of the output generated. Is there a way to display nodes and connecting lines? What C++ classes would required achieve this?

View 2 Replies View Related

C++ :: Simple Image Output - Setting RGB Values And X-Y Coordinates

May 21, 2012

I'm wanting to create an image, all I need is to be able to set RGB values and X-Y coordinates, I'm not wanting to read or manipulate images. Any easy to use library or another simple method of doing this?

View 1 Replies View Related

C++ :: Converting User Input Int To String Output?

Apr 22, 2014

I am writing a code in a class that will change the user input which is integer to a string. For example if the user enter 13347..the output should change to "one three three four seven" on the user screen.I'm not getting the right output.

Code below:

#include <iostream>
#include <string>
using namespace std;
string arr[]={"one","two","three","four","five","six","seven","eight","nine"};
class convertTo{
public:
int signed num;
int convet(){
cout<<"Enter a number to convert to string "; cin>>num;

[code]....

View 2 Replies View Related

C/C++ :: Converting Uesr Input Int To String Output

Apr 22, 2014

I am writing a code in a class that will change the user input which is integer to a string. For example if the user enter 13347..the output should change to "one three three four seven" on the user screen.I'm not getting the right output.

Code below.

#include <iostream>
#include <string>
using namespace std;
string arr[]={"one","two","three","four","five","six","seven","eight","nine"};
class convertTo{
public:
int signed num;

[Code] ....

View 5 Replies View Related

C++ :: Compound Interest Formula

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

C++ :: Turning A Limited Float Into Another Float?

Nov 20, 2013

I can do the folowing:

float var1 ;
var1 = 9.12345 ;
printf("%.2f",var1) ;

the output will be 9.12. What if I wanted to save that as another separate float with displaying it on screen?

View 1 Replies View Related

C/C++ :: Cannot Convert Float To Float Assignment

Jun 8, 2014

#include <iostream>
#include <string.h>
#include <sstream>

[Code]....

View 1 Replies View Related

C++ :: Daily Interest Rate For Savings

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

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 View Related

C/C++ :: Interest Calculator Math Part

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

C/C++ :: Calculating Interest Earned On Bank-account

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

C++ :: Calculating Interest And Making Nested Loops Not Working

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

C++ :: Loan Payment Table - Top Increments And Interest Rate

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

C++ :: How To Covert Int To Float

Oct 12, 2013

I have a question here

How I want to convert an int to float in the middle of the program

#include <iostream>
using namespace std;
int main()
{
int x;
float y;
cin>> x;
y= (float)x;
cout<< y;
}

is this line correct y= (float)x;?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved