Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- private static void compute(float[] total) //自訂compute方法
- {
- float sum = total[0] * (1 + (total[1]/100) / 12) ^(12*total[2]); //本和利公式
- Console.WriteLine("本利和為:{0}", sum); //印出本和利總額
- }
- static void Main(string[] args)
- {
- float[] interest = new float[3];
- for (int i = 0; i <= 2; i++)
- {
- if (i == 0)
- {
- Console.Write("1. 請輸入本金:");
- interest[i] = float.Parse(Console.ReadLine());
- }
- else if (i == 1)
- {
- Console.Write("2. 請輸入年利率:");
- interest[i] = float.Parse(Console.ReadLine());
- }
- else
- {
- Console.Write("3. 請輸入存款年數:");
- interest[i] = float.Parse(Console.ReadLine());
- }
- }
- compute(interest);
- Console.Read();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement