Computer Science, asked by faoif7252, 11 months ago

Write a program to calculate simple interest using c++

Answers

Answered by QGP
6

Simple Interest in C++

We are tasked with making a Simple Interest Calculation Program in C++.

The formula for Simple Interest (I) is given by:

I = \dfrac{P\times R\times N}{100}

where:

P = Principal

R = Rate of Interest

N = Number of Years (or Time)

So, from a Programming perspective, we must first take user input for the values of P, R and N. We will keep their data types as double to account for fractional values as well.

After that we can calculate the Simple Interest using the formula and display it to the user.

\rule{300}{1}

C++ Code:

#include <iostream>

using namespace std;

int main()

{

   double P,R,N;

   cout << "Simple Interest Calculator" << endl;

   cout << "Enter Principal (P): ";

   cin >> P;

   cout << "Enter Rate of Interest (R): ";

   cin >> R;

   cout << "Enter Number of Years (N): ";

   cin >> N;

   double I = P*R*N/100;

   cout << "The Simple Interest is I = " << I << endl;

   return 0;

}

\rule{300}{1}

Screenshots of Code and a Runtime Example are attached.

Attachments:
Similar questions