Untitled
unknown
plain_text
3 years ago
2.4 kB
5
Indexable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HW1
{
class Program
{
int optionfunc, num, optionfood;
int[] total = new int[] {0,0,0,0,0};
static void Main(string[] args)
{
do{
Console.WriteLine("(1)輸入收入 (2)輸入支出 (3)計算比例 (4)剩餘金額 (5)退出程式");
Console.WriteLine("輸入數字選擇功能:");
}while (option != 5);
Environment.Exit(0);
}
static void helper(int optionfunc)
{
switch(optionfunc)
{
case 1:
helper2();
break;
case 2:
helper3();
break;
case 3:
helper4();
break;
case 4:
helper5();
break;
case 5:
Environment.Exit(0);
break;
}
}
static void helper2(){
Conosle.WriteLine("(1)食 (2)衣 (3)住 (3)行 (4)育樂");
optionfood = Conosle.ReadLine();
Conosle.WriteLine("輸入支出輸入支出金額:");
total[optionfood - 1] += Console.ReadLine();
}
static void helper3(){
Conosle.WriteLine("(1)食 (2)衣 (3)住 (3)行 (4)育樂");
optionfood = Conosle.ReadLine();
Conosle.WriteLine("輸入支出金額:");
total[optionfood - 1] -= Console.ReadLine();
}
static void helper4(){
int currentTotal = 0;
foreach (int i in total)
{
currentTotal += i;
}
Conosle.WriteLine("(1)食: {1:p}",total[0]/currentTotal);
Conosle.WriteLine("(2)衣: {1:p}",total[1]/currentTotal);
Conosle.WriteLine("(3)住: {1:p}",total[0]/currentTotal);
Conosle.WriteLine("(4)行: {1:p}",total[0]/currentTotal);
Conosle.WriteLine("(5)育樂: {1:p}",total[0]/currentTotal);
}
static void helper5(){
int currentTotal = 0;
foreach (int i in total)
{
currentTotal += i;
}
Conosle.WriteLine("剩餘金額為: {0:d}", currentTotal);
}
}
}
Editor is loading...