2018-10-25運算符

1.半徑為5的圓
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int r = 5;
double pi = 3.14;
double total1 = pi * r * r;
double total2 = pi * 2 * r;
Console.WriteLine("面積是{0},周長是{1}", total1, total2);
Console.ReadKey();

    }
}

}

2.語數英成績
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("請輸入你的姓名");
string name=Console.ReadLine();

        Console.WriteLine("請輸入你的語文成績");
        string str_Chinese = Console.ReadLine();
        double chinese = Convert.ToDouble(str_Chinese);

        Console.WriteLine("請輸入你的數學成績");
        string str_Math= Console.ReadLine();
        double math = Convert.ToDouble(str_Math);

        Console.WriteLine("請輸入你的英語成績");
        string str_English = Console.ReadLine();
        double english = Convert.ToDouble(str_English);

        int Chinese = Convert.ToInt32(str_Chinese);
        int Math = Convert.ToInt32(str_Math);
        int English = Convert.ToInt32(str_English);

        //總分
        int total = Chinese + Math + English;
       
        //平均分
        double avg = total / 3.0;

        Console.WriteLine("總共應付:{0},平均分是:{1}", total,avg);
        
        Console.ReadKey();
        

    }
}

}

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容