Not sure how to write the last of this source code.

this is what i have thus far and to no avail i have yet to figure out how to write the last bit of this algorithm included after my source code any help is good help at this point i think im just making it worse the more i try im sure its something easyer then what im trying to do..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
   int amount, newAmount, intevpludrestRate;
   
   cout <<"Please enter the dollar amount."<<endl;

cin>> amount; 
             
    cout <<"Please enter the interest rate(e.g., nine percet should be entered as 9.0). "<<endl;

cin>> interestRate;                            
                    
return 0;
}



algorithm i have to work with.
// Start
// Declarations
// num amount
// num newAmount
// num interestRate
// output "Please enter the dollar amount. "
// input amount
// output "Please enter the interest rate(e.g., nine percet should be entered as 9.0). "
// input interestRate
// newAmount = FutureValue(amount,interestRate)
// output "The new dollar amount is ", newAmount
// Stop
//
//
//
// num FutureValue(num initialAmount, num interestRate)
// Declarations
// num finalAmount
// finalAmount = (1 + interestRate/100) * initialAmount
// return finalAmount
i think i have everything ok but beyond the point i stopped at i am lost what i have is error free at least ;/
1
2
3
4
5
6
 newAmount = ( amount, interestRate); { 
             cout <<"The new dollar amount is ", newAmount"<<endl; cin>>;               
              }                     
                    
return 0;
} 


says missing character not a clue what that means is this close to that example.
Your function call does not have the name of the function that you want to call.
it means int newAmount if you are going to return 0 which is unnecessary
just make it void and newAmount and after that you have a bunch of problems on line 2
for 1) you should have << where the comma is.
2) remove the " after newAmount.
and 3) why do you have a cin?
and 4) you should probably update the new dollar amount before printing
eg:
1
2
 amount *= (interestrate/100);
std::cout << "The new amount is: " <<  amount << std::endl;
Last edited on
hmm so i removed the " i dont see the << your talking about and removed the cin>> not sure i thought it was needed on a cout stament and the return 0 i just used so i can compile it for errors and run it so i know what im doing works for the moment..

1
2
3
4
5
6
7
 newAmount = ( amount, interestRate); { 
             cout <<"The new dollar amount is ", newAmount<<endl;                
              }                     
                    
return 0; 
  lol
}
[/code]
oh i needed <<
are you saying the updated new dollar amount should go before do i put it before the other function

this is what i understood .
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
   int amount, newAmount, interestRate;
   
   cout <<"Please enter the dollar amount."<<endl;

cin>> amount; 
             
    cout <<"Please enter the interest rate(e.g., nine percet should be entered as 9.0). "<<endl;

cin>> interestRate;   
newAmount = ( amount, interestRate); {  amount *= (interestRate/100);
std::cout << "The new amount is: " <<  amount << std::endl;
             cout <<"The new dollar amount is "<< newAmount<<endl;                
             
              }                     
                    

return 0;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
   int amount, newAmount, interestRate;
   
   cout <<"Please enter the dollar amount."<<endl;

cin>> amount; 
             
    cout <<"Please enter the interest rate(e.g., nine percet should be entered as 9.0). "<<endl;

cin>> interestRate;   
newAmount = ( amount, interestRate); {  amount *= (interestRate/100);
std::cout << "The new amount is: " <<  amount << std::endl;
             cout <<"The new dollar amount is "<< newAmount<<endl;                
             
              }                     
                    

return 0;
}


// i know this is incomplete i do not know what i am to do next i have some idea just do not know how to make the function properly i guess . can some one help me figure this out the algorithm is below

alogrithm:
// Start
// Declarations
// num amount
// num newAmount
// num interestRate
// output "Please enter the dollar amount. "
// input amount
// output "Please enter the interest rate(e.g., nine percet should be entered as 9.0). "
// input interestRate
// newAmount = FutureValue(amount,interestRate)
// output "The new dollar amount is ", newAmount
// Stop
//
//
//
// num FutureValue(num initialAmount, num interestRate)
// Declarations
// num finalAmount
// finalAmount = (1 + interestRate/100) * initialAmount
// return finalAmount
I did point you to tutorials. Their first example has function "addition". Your instructions require function "FutureValue".
By the way you are trying create a function inside your main function
there are 2 options
1
2
3
4
5
6
7
8
int newAmount(int a, int b)
{
//do stuff
}
int main()
{
amount = newAmount(amount, interestRate);
}


or
1
2
3
4
5
int main()
{
newAmount = amount *= (interestRate / 100);
std::cout << newAmount << std::endl;
}
Last edited on
Topic archived. No new replies allowed.