C# Program to Calculate the Simple Interest.

Calculating simple interest is a basic financial calculation used to determine the interest earned or paid on a principal amount over a specific period. In this article, we'll learn how to write a C# program to calculate simple interest.


Problem Statement: Write a C# program to calculate the simple interest given the principal amount, rate, and time.

Example:

Suppose the principal amount is $1000, the interest rate is 5%, and the time is 3 years. The program should output:

Simple Interest: $150.00

Steps to Find Simple Interest.

Below are steps that you need to follow to calculate simple interest:

Step 1: Take inputs for principal amount, rate, and time from the user.
Step 2: Calculate simple interest using the formula: Simple Interest = (Principal * Rate * Time) / 100.
Step 3: Print the calculated simple interest.

C# Code to Find Simple Interest.

// C-sharp code implementation to calculate simple interest
using System;

namespace SimpleInterestCalculator
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Enter the principal amount: ");
            double principal = Convert.ToDouble(Console.ReadLine());

            Console.Write("Enter the interest rate (in percentage): ");
            double rate = Convert.ToDouble(Console.ReadLine());

            Console.Write("Enter the time (in years): ");
            double time = Convert.ToDouble(Console.ReadLine());

            double simpleInterest = (principal * rate * time) / 100;

            Console.WriteLine($"Simple Interest: ${simpleInterest:F2}");
        }
    }
}
Output:
Enter the principal amount: 1000
Enter the interest rate (in percentage): 8
Enter the time (in years): 4
Simple Interest: $320.00

Similar articles:

⚡ Please share your valuable feedback and suggestion in the comment section below or you can send us an email on our offical email id ✉ algolesson@gmail.com. You can also support our work by buying a cup of coffee ☕ for us.

Similar Posts

No comments:

Post a Comment


CLOSE ADS
CLOSE ADS