#include <iostream>

                    #include <string>

     Void main()
             {
                    int p;
                    A=0;
                    int j;
                    int R; 
                    int D;
                    cout<<"enter cost of stereo purchase \n"";
                    cin>>P;
                    cout<<"enter Rate of interest per month \n ";
                    Cin>>R;
                    cout<<"enter period or Time \n";
                    cin>>T;
                    cout<<"enter monthly payment\n";
                    cin>>D;
                    do
                       { I=(P*R*T)/100;
                       A=I;
                       A=A+I;
                       M=P-I;
                       P=P-M;
                       j=j+1
                       }
                       while(P>=D)

                             {  cout<<"the monthsit will take you to pay off 
                                       the loan is "j;
                                 cout<<"the Amout of intrest of intrest paid 
                                      over the life of loan  is"A;
                            }
       getch()
      system ("pause");              

}

Edited 3 Years Ago by Dani: Formatting fixed

First off, please put your code inside tags -- It is in the rules!!!!!!

#include <iostream>
#include <string>

int main()
{
int p;
A=0;
int j;
int R; 
int D;
int I;
int A;
int M;
int P;
int j;

cout << "enter cost of stereo purchase \n";
cin >> p;
cout<< "enter Rate of interest per month \n ";
cin>>R;
cout<<"enter period or Time \n";
cin >> T;
cout << "enter monthly payment\n";
cin >> D;
do
{ 
I=(P*R*T)/100;
A=I;
A=A+I;
M=P-I;
P=P-M;
j=j+1
}while(P>=D);

cout<<"the monthsit will take you to pay off the loan is " << j << endl;
cout<<"the Amout of intrest of intrest paid over the life of loan is" << A << endl;

getch();
system ("pause"); 
return EXIT_SUCSESS;
}

Your code is rather messy, this should work although I haven't compiled it.

@dangutdavid and Phil++ :

Both of you need to understand your basics well because without it you cant code anything.

Error 1 : Line 7 : Initializing A even before declaring it.
Error 2 : Line 38 : getch() ???

And please tell me that this program has no logic,the do while loop is a complete mess.

A=I;
A=A+I;

=> A=2*I or I+I and nothing else.

M=P-I;
P=P-M;

=>M=P-I
=>P=P-M=>P-(P-I)=>I

==>M=P-I
==>P=I

j=j+1
j was initially uninitialised hence it would be garbage + 1.

This article has been dead for over six months. Start a new discussion instead.