OOPc using C++

With this blog I want to share my knowledge of OOPs and C++. I Hope this can quench your thirst for learning.Any suggestions and comments are welcome.

Friday, August 6, 2010

Program 10 - Simple Interest (Asked in the test on 6/8/10)


This program takes in the prinicipal, rate and time as a screen input from the user.
The program is executed (run) 5 times using the 'FOR' loop.
It calculates the simple interest using the formula I = PTR/100.
The principal, rate, time and the simple interest are then outputted using the 'cout' command.

#include <iostream.h>
#include <conio.h>

void main()
{
     clrscr();
     int i;
     float  fsinterest,fprincipal,frate,ftime;
     for(i=4;i>=0;i--)
       {
          cout << "Enter the principal, rate & time : " << endl;
          cin>>fprincipal>>frate>>ftime;
          fsinterest=(fprincipal*frate*ftime)/100;
          cout << "Principal = $" << fprincipal << endl;
          cout << "Rate = " << frate << "%" << endl;
          cout << "Time = " << ftime << " years" << endl;
          cout << "Simple Interest = $" << fsinterest << endl;
        }
getch();
}

2 comments: