Write a program in C# that calculates the Simple Interest and Compound Interest. (The Principal, Amount, Rate of Interest and Time are entered through the keyboard)..
Following is the simple C# code :
Output:-
Following is the simple C# code :
class Lab { static void Main(string[] args) { double principleAmount, rateOfInterest, simpleInterest, CompoundInterest; int numberOfyears; Console.Write("Enter Principle Amount : "); principleAmount = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter Nmuber of years : "); numberOfyears = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter the rate of interest : "); rateOfInterest = Convert.ToDouble(Console.ReadLine()); simpleInterest = (principleAmount * numberOfyears * rateOfInterest) / 100; CompoundInterest = principleAmount * (Math.Pow(1 + (rateOfInterest/ 100), numberOfyears) - 1); Console.WriteLine("Simple Interest : {0}", simpleInterest); Console.WriteLine("Compound Interest : {0}", CompoundInterest); Console.ReadLine(); } }
Output:-
No comments:
Post a Comment
Note: only a member of this blog may post a comment.