. Net (read two numbers from the console to implement addition, subtraction, multiplication, division)

Source: Internet
Author: User

[Csharp]
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
 
Namespace TestClaclulate
{
Class Program
{
Static void Main (string [] args)
{
// 1. Define the double variable.
Double numberOne;
Double numberTwo;
 
// 2. obtain two numbers from the console
Try
{
NumberOne = double. Parse (Console. ReadLine ());
NumberTwo = double. Parse (Console. ReadLine ());
 
// 3. output the result of the addition, subtraction, multiplication, and division of the two numbers.
Console. WriteLine (numberOne + "+" + numberTwo + "=" + (numberOne + numberTwo ));
Console. WriteLine (numberOne + "-" + numberTwo + "=" + (numberOne-numberTwo ));
Console. WriteLine (numberOne + "*" + numberTwo + "=" + (numberOne * numberTwo ));
Console. WriteLine (numberOne + "/" + numberTwo + "=" + (numberOne/numberTwo ));
}
Catch (System. FormatException e)
{
Console. WriteLine (e. Message );
}
 
//
Console. ReadKey ();
}
}
}
Author: haifengzhilian

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.