#作業(yè)要求
估計一個職員在65歲退休之前能賺到多少錢。用年齡和超始薪水作為輸入,并假設(shè)職員每年工資增長5%。
#程序
namespace ConsoleApplication1
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? Console.WriteLine("請輸入你的年齡");
? ? ? ? ? ? string str_age = Console.ReadLine();
? ? ? ? ? ? Console.WriteLine("請輸入你現(xiàn)在的工資");
? ? ? ? ? ? string str_gz = Console.ReadLine();
? ? ? ? ? ? try
? ? ? ? ? ? {
? ? ? ? ? ? ? ? int age = Convert.ToInt32(str_age);
? ? ? ? ? ? ? ? Double gz = Convert.ToDouble(str_gz);
? ? ? ? ? ? ? ? Double sum = gz;
? ? ? ? ? ? ? ? while (age<65)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? sum = sum + gz * 1.05;
? ? ? ? ? ? ? ? ? ? age++;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? Console.WriteLine("你到65歲時,可以領(lǐng)到{0}", sum);
? ? ? ? ? ? }
? ? ? ? ? ? catch
? ? ? ? ? ? {
? ? ? ? ? ? ? ? Console.WriteLine("格式輸入錯誤");
? ? ? ? ? ? }
? ? ? ? ? ? Console.ReadKey();
? ? ? ? }
? ? }
}