Advertisement
Guest User

Untitled

a guest
Aug 13th, 2016
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. class Program
  2. {
  3. private static void compute(float[] total) //自訂compute方法
  4. {
  5. float sum = total[0] * (1 + (total[1]/100) / 12) ^(12*total[2]); //本和利公式
  6. Console.WriteLine("本利和為:{0}", sum); //印出本和利總額
  7. }
  8.  
  9. static void Main(string[] args)
  10. {
  11. float[] interest = new float[3];
  12. for (int i = 0; i <= 2; i++)
  13. {
  14. if (i == 0)
  15. {
  16. Console.Write("1. 請輸入本金:");
  17. interest[i] = float.Parse(Console.ReadLine());
  18. }
  19. else if (i == 1)
  20. {
  21. Console.Write("2. 請輸入年利率:");
  22. interest[i] = float.Parse(Console.ReadLine());
  23. }
  24. else
  25. {
  26. Console.Write("3. 請輸入存款年數:");
  27. interest[i] = float.Parse(Console.ReadLine());
  28. }
  29. }
  30. compute(interest);
  31. Console.Read();
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement