C++
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
float principal, rate, time, interest, totalAmount;
cout << "Enter principal amount: ";
cin >> principal;
cout << "Enter interest rate (per year): ";
cin >> rate;
cout << "Enter time period (in years): ";
cin >> time;
// Calculate simple interest
interest = (principal * rate * time) / 100.0;
// Calculate total amount
totalAmount = principal + interest;
cout << fixed << setprecision(2);
cout << "\nSimple Interest: " << interest << endl;
cout << "Total Amount: " << totalAmount << endl;
return 0;
}Output
Enter principal amount: 10000 Enter interest rate (per year): 5 Enter time period (in years): 2 Simple Interest: 1000.00 Total Amount: 11000.00
Calculate Simple Interest in C++
This program calculates simple interest, which is a fundamental concept in finance and banking. Simple interest is calculated using the formula: ## Interest = Principal × Rate × Time / 100.
Understanding Simple Interest
Simple interest is the interest calculated only on the original principal amount. It does not compound (unlike compound interest).
Formula:
- Simple Interest = (Principal × Rate × Time) / 100
- Total Amount = Principal + Interest
Key Components
-
Principal (P): The original amount of money
-
Rate (R): The interest rate per year (as a percentage)
-
Time (T): The time period in years
-
Interest (I): The interest earned
-
Total Amount: Principal + Interest
Program Flow
- Read principal amount from user
- Read interest rate from user
- Read time period from user
- Calculate interest using the formula
- Calculate total amount
- Display both interest and total amount
Example Calculation
If:
- Principal = ₹10,000
- Rate = 5% per year
- Time = 2 years
Then:
- Interest = (10000 × 5 × 2) / 100 = ₹1,000
- Total Amount = 10,000 + 1,000 = ₹11,000
Key Takeaways
1
Simple interest formula: I = (P × R × T) / 100
2
Total amount = Principal + Interest
3
Use float for decimal values (rate, amounts)
4
Format output for readability