Write C# program to calculate compound Interest


Introduction

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability.

techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. public class csharpExercise
  7. {
  8. static void Main(string[] args)
  9. {
  10. float amount, rate, intrest, time, ci, a;
  11.  
  12. /*Reading amount, rate of intrest
  13.   and period in years from user
  14.   */
  15.  
  16. Console.Write("Type the amount : ");
  17. amount = Convert.ToInt32(Console.ReadLine());
  18.  
  19. Console.Write("Type the interest rate : ");
  20. rate = Convert.ToInt32(Console.ReadLine());
  21.  
  22. Console.Write("Type the period in years: ");
  23. time = Convert.ToInt32(Console.ReadLine());
  24.  
  25. intrest = 1+(rate/100);
  26.  
  27. // ci=pow(intrest,time);
  28. ci = 1;
  29. for(a = 1; a <= time; a++)
  30. ci = ci * intrest;
  31.  
  32. ci = amount * ci - amount;
  33.  
  34. Console.WriteLine("Your compound interest is : "+ ci);
  35.  
  36.  
  37.  
  38. Console.ReadLine();
  39. }
  40. }

Result

C# language techstudy

     





Related Topics




Popular Posts