Program to Compute Simple Interest
- Write a program to Compute Simple Interest in C
- Write a program to Compute Simple Interest in C++
- Write a program to Compute Simple Interest in Python
- Write a program to Compute Simple Interest in PHP
- Write a program to Compute Simple Interest in Java
- Write a program to Compute Simple Interest in Java Script
- Write a program to Compute Simple Interest in C#
Explanation:
This application calculates simple interest in a number of different programming languages. The following is the formula for simple interest:
Simple interest = (P x R x T) / 100
Where:
- P is the Principal amount.
- R is the Rate of interest per annum.
- T is the Time period in years.
Program to Compute Simple Interest
-
C
-
C++
-
Python
-
PHP
-
JAVA
-
Java Script
-
C#
<div class="contain-inline-size rounded-md border-[0.5px] border-token-border-medium relative bg-token-sidebar-surface-primary dark:bg-gray-950"><div class="overflow-y-auto p-4" dir="ltr"><code class="!whitespace-pre hljs language-c">#include <stdio.h>
int main() {
float P, R, T, SI;
// Input the principal, rate, and time
printf("Enter principal amount: ");
scanf("%f", &P);
printf("Enter rate of interest: ");
scanf("%f", &R);
printf("Enter time period (in years): ");
scanf("%f", &T);
// Calculate Simple Interest
SI = (P * R * T) / 100;
// Output the result
printf("Simple Interest = %.2f\n", SI);
return 0;
}
#include <iostream>
using namespace std;
int main() {
float P, R, T, SI;
// Input the principal, rate, and time
cout << "Enter principal amount: ";
cin >> P;
cout << "Enter rate of interest: ";
cin >> R;
cout << "Enter time period (in years): ";
cin >> T;
// Calculate Simple Interest
SI = (P * R * T) / 100;
// Output the result
cout << "Simple Interest = " << SI << endl;
return 0;
}
P = float(input("Enter principal amount: "))
R = float(input("Enter rate of interest: "))
T = float(input("Enter time period (in years): "))
# Calculate Simple Interest
SI = (P * R * T) / 100
# Output the result
print(f"Simple Interest = {SI:.2f}")
<?php
// Input the principal, rate, and time
$P = (float)readline("Enter principal amount: ");
$R = (float)readline("Enter rate of interest: ");
$T = (float)readline("Enter time period (in years): ");
// Calculate Simple Interest
$SI = ($P * $R * $T) / 100;
// Output the result
echo "Simple Interest = " . number_format($SI, 2) . "\n";
?>
import java.util.Scanner;
public class SimpleInterest {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Input the principal, rate, and time
System.out.print("Enter principal amount: ");
double P = scanner.nextDouble();
System.out.print("Enter rate of interest: ");
double R = scanner.nextDouble();
System.out.print("Enter time period (in years): ");
double T = scanner.nextDouble();
// Calculate Simple Interest
double SI = (P * R * T) / 100;
// Output the result
System.out.printf("Simple Interest = %.2f\n", SI);
scanner.close();
}
}
let P = parseFloat(prompt("Enter principal amount: "));
let R = parseFloat(prompt("Enter rate of interest: "));
let T = parseFloat(prompt("Enter time period (in years): "));
// Calculate Simple Interest
let SI = (P * R * T) / 100;
// Output the result
console.log(`Simple Interest = ${SI.toFixed(2)}`);
using System;
class Program {
static void Main() {
// Input the principal, rate, and time
Console.Write("Enter principal amount: ");
double P = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter rate of interest: ");
double R = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter time period (in years): ");
double T = Convert.ToDouble(Console.ReadLine());
// Calculate Simple Interest
double SI = (P * R * T) / 100;
// Output the result
Console.WriteLine($"Simple Interest = {SI:F2}");
}
}