I have this code and the compiler is saying
<New.cpp:3:1: error: expected ‘{’ before ‘int’
New.cpp:4:1: error: expected unqualified-id before ‘{’ token
New.cpp:29:1: error: expected ‘}’ at end of input>
This is the code:
<#include <iostream>
namespace std
int main();
{
double interest_rate,loan,balance_due,balance,payment;
double actual_payment,interest_paid;
int count;
cout<<"How much do the object cost?\n";
cin>>loan;
cout<<"What is the interest rate of your credit card?\n";
cin>>interest_rate;
cout<<"How much do you pay monthly?\n";
cin>>payment;
cout<<"To pay $ "<<loan<<" , with your monthly payment and interest rate, would take "<<count<<;
cout<<" months, and you would have paid $ "<<interest_paid<<" in interest.\n";
I fix it but i got an infinite loop, can you help me
This is the loop body:
for(count=0;balance_due>0;count++)
{
balance=loan;
actual_payment=payment-(interest_rate*balance);
balance_due=balance-actual_payment;
}
you can see the problem debugging the source, and watching
the contents of vars with control above the final condition of the loop.
I'm also starting with c++, but try:
[ code]
your code goes here
[ /code]
dont use the spaces between [ code and [ /code though.
im just letting you know, because i know some people get frustrated when the coding is not neat and more readable like the example dalazul showed, im not trying to be mean or anything, just trying to give you a heads up.