1、
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
/**
*
* 编写程序,估计一个职员在65岁退休之前能赚到多少钱
* 。用年龄和超始薪水作为输入,并假设职员每年工资增长5%。
* */
Console.WriteLine("职员贵庚");
string str_year = Console.ReadLine();
int year = Convert.ToInt32(str_year);
Console.WriteLine("职员原始薪水");
string str_money = Console.ReadLine();
double money = Convert.ToInt32(str_money);
double sum = 0;
while (year < 65)
{
year++;
money = money * 1.05;
sum = sum + money;
}
Console.WriteLine("职员在65岁退休前能拿到赚到{0}钱", sum);
Console.ReadKey();
}
}
}
2、
Console.WriteLine("请输入你现在的工资");
string str_salar = Console.ReadLine();
Console.WriteLine("请输入你的年龄");
string str_age = Console.ReadLine();
double salar=0;
int age = 0;
double sum = salar;
bool flag = true;
try
{
salar = Convert.ToDouble(str_salar);
age = Convert.ToInt32(str_age);
flag = true;
}
catch
{
Console.WriteLine("你输入的格式错误");
flag = false;
}
if (flag)
{
while (age <= 65)
{
salar *= 1.05;
sum += salar;
age++;
}
Console.WriteLine("你到65岁退休之前的工资和是:{0}", sum);
}
Console.WriteLine("程序执行完毕");
Console.ReadKey();
}
}
}
网友评论