Write a program to calculate simple Interest

Problem statement:- Program to calculate Simple Interest.

Data requirement:-

   Input Data:-principle, rate, time

  Output Data:-
simple_interest

Program in C

Here is the source code of the C Program to Program to calculate Simple Interest.

Code:

#include<stdio.h>
int main()
{
    double principle,rate,time,simple_interest;
    printf("Enter the Principle:");
    scanf("%lf",&principle);

    printf("Enter the Rate:");
    scanf("%lf",&rate);

    printf("Enter the Time(year):");
    scanf("%lf",&time);

    simple_interest=(principle*rate*time)/100.0;

    printf("The Simple Interest: %lf",simple_interest);
}

Input/Output:
Enter the Principle:500
Enter the Rate:5
Enter the Time(year):3
The Simple Interest: 75.00

Program in C++

Here is the source code of the C++ Program to Program to calculate Simple Interest.

Code:

#include<iostream>
using namespace std;
int main()
{

    double principle,rate,time,simple_interest;
    cout<<"Enter the Principle:";
    cin>>principle;

    cout<<"Enter the Rate:";
    cin>>rate;

    cout<<"Enter the Time (Year):";
    cin>>time;

    simple_interest=(principle*rate*time)/100.0;

    cout<<"The Simple Interest: "<<simple_interest;
}

Input/Output:
Enter the Principle:600
Enter the Rate:7.5
Enter the Time (Year):2
The Simple Interest: 90

Program in Java

Here is the source code of the Java Program to Program to calculate Simple Interest.

Code:

import java.util.Scanner;
public class SimpleInterest {

public static void main(String[] args) {

          Scanner cs=new Scanner(System.in);
    double principle,rate,time,simple_interest;
    System.out.println("Enter the Principle:");
    principle=cs.nextDouble();

    System.out.println("Enter the Rate:");
    rate=cs.nextDouble();

    System.out.println("Enter the Time(year):");
    time=cs.nextDouble();

    simple_interest=(principle*rate*time)/100.0;

    System.out.println("The Simple Interest: "+simple_interest);

            cs.close();
}
}

Input/Output:
Enter the Principle:
700.55
Enter the Rate:
3.55
Enter the Time(year):
3
The Simple Interest: 74.608575

Program in Python

Here is the source code of the Python Program to Program to calculate Simple Interest.

Code:

principle=float(input("Enter a principle:"))
rate=float(input("Enter a rate:"))
time=float(input("Enter a time(year):"))

simple_interest=(principle*rate*time)/100;

print("Simple Interest:",simple_interest)

Input/Output:
Enter a principle:10000
Enter a rate:5.5
Enter a time(year):3
Simple Interest: 1650.0

Post a Comment

0 Comments