# PHSARIT

Bring Technology Ideas with you The definition of Interest Rate and Compound Interest Rate. In this C++ program to calculate simple interest and Compound Interest Rate, We define four variables p, t, r, and i which stores principal amount, time, rate, and interest rate Using the formula of simple interest and compound interest. As the simple interest is calculated by the formula i=(p*r*t)/100 and the compound interest within the formula is ci=(p*pow(1-i,t)-p)

To work with these calculation in C++, please a new project (visit our previous post How to create a project using C++ programming in Visual Studio. Then using this code below:

``````#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double p, t, r, i, ci;//variables for formulas
// i=(p*r*t)/100 simple interest rate
// ci=(p*pow(1-i,t)-p) compound interest rate
char choice;
cout << "What do you want to look for?\n" << "1. Find Simple Interest Rate.\n" << "2. Find Compound Interest Rate:\n" <<"Please type number 1 or 2"<<endl;
cin >> choice;
switch (choice)
{
case '1': //find simple interest rate
cout << "You are finding simple interest rate" << endl;
cout << "---------------------------------------------" << endl;
cin >> p;
cin >> r;
cin >> t;
i = (p*t*r) / 100;
cout << "Your simple interest rate is:\t" << i;
break;
case '2':
cout << "You are finding compound interest rate" << endl;
cout << "---------------------------------------------" << endl;
cin >> p;
cin >> i;
cin >> t;
ci = p*pow(1-i,t)-p;
cout << "Your simple interest rate is:\t" << ci;
break;
default:
cout << "No selection has chosen";
break;
}
system("pause > 0");
}``````

The programming above is using choice as an option for users who can get the their options for choosing whether they want to calculate simple interest or compound interest.

Programming

Programming

Programming