본문 바로가기
IT/C#

C# (성적의 총점과 평균 출력)

by hjshims 2021. 5. 6.

성적의 총점과 평균을 출력하는 프로그램

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RoadBook.CsharpBasic.Chapter01.Examples
{
    class Ex007
    {
        public void Run()
        {
            int kor = 100;
            int eng = 100;
            int mat = 98;
            int phy = 97;

            int total = kor + eng + mat + phy;

            Console.WriteLine("성적 총점: {0}", total, kor);
            Console.WriteLine("평균: {0}", (double)total / 4);
        }
    }
}

<출력결과>