使用数字运算符处理变量

freful student  2015-12-13 08:51:44
程序下l好几天都还没有下好 渣渣校园网

program.cs

static void Main(string[] args)
{
double firstNumber, secondNumaber ;
string userName;
Console.WriteLine("Enter you name:");
userName = Console.ReadLine();
Console.WriteLine("Weclome {0}!", userName);
Console.WriteLine("Now gine me a number");
firstNumber = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Now give me another number:");
secondNumber =Console.ToDouble(Console.ReadLine());
Console.WriteLine("The sum of {0} and {1} is {2}.", firstNumber,secondNumber,firstNumber+secondNumber );
Console.WriteLine("The resultof subtracting {0} from {1} is {2}.", firstNumber,secondNumber,firstNumber-secondNumber );
Console.WriteLine("The product of {0} and {1} is {2}.", firstNumber,secondNumber,firstNumber*secondNumber );
Console.WriteLine("The result of dividing {0} by {1} is {2}.", firstNumber,secondNumber,firstNumber/secondNumber );
Console.WriteLine("The remainder after dividing of {0} by {1} is {2}.", firstNumber,secondNumber,
firstNumber%secondNumber );
Console.Readkey();
}
...全文
68 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
是报异常了吗,如果你输入的字符串不是double?那么就用double.TryParse替换
回复
freful 2015-12-14
对不起大家,我发的是帖子,发错地方了!!@starfd 请删除
回复
风云再起9310 2015-12-13
楼主遇到什么问题?
回复
相关推荐
发帖
非技术区
创建于2007-09-28

7707

社区成员

.NET技术 非技术区
申请成为版主
帖子事件
创建了帖子
2015-12-13 08:51
社区公告
暂无公告