首页上一页 1 下一页尾页 1 条记录 1/1页
console.writeline();
发表在C#图书答疑
2013-02-13
是否精华
是
否
版块置顶:
是
否
namespace P_46
{
class Program
{
static void Main(string[] args)
{
decimal amount;
decimal principal;
double rate = 0.05;
int n;
string output = "年" + "\t" + "复利存款" + "\n";
int year = 1;
Console.WriteLine("请输入用户开始存入的金额数:");
principal = decimal.Parse(Console.ReadLine());
Console.WriteLine("请输入用户存款年数:");
n = int.Parse(Console.ReadLine());
while (year<=n)
{
amount=principal*(decimal)Math.Pow((1+rate),year);
output+=year.ToString()+"\t"+string.Format("{0:c}",amount)+"\n";
year++;
}
Console.WriteLine(output);[font face=楷体_GB2312][font size=4]/[font color=#FF0000][strong]/为什么会循环输出各个每次变换的output?它没在while里边啊[/strong][/font][/font][/font]
Console.Read();
}
}
}
{
class Program
{
static void Main(string[] args)
{
decimal amount;
decimal principal;
double rate = 0.05;
int n;
string output = "年" + "\t" + "复利存款" + "\n";
int year = 1;
Console.WriteLine("请输入用户开始存入的金额数:");
principal = decimal.Parse(Console.ReadLine());
Console.WriteLine("请输入用户存款年数:");
n = int.Parse(Console.ReadLine());
while (year<=n)
{
amount=principal*(decimal)Math.Pow((1+rate),year);
output+=year.ToString()+"\t"+string.Format("{0:c}",amount)+"\n";
year++;
}
Console.WriteLine(output);[font face=楷体_GB2312][font size=4]/[font color=#FF0000][strong]/为什么会循环输出各个每次变换的output?它没在while里边啊[/strong][/font][/font][/font]
Console.Read();
}
}
}