프로그래밍/코드 정리

[C#] 성적 프로그램

NIA1995 2021. 3. 20. 19:53
using System;
using System.Threading;
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test
{
    class Program
    {
        int[] arrweek = new int[7]{1,2,3,4,5,6,7};

        /* 성적 프로그램 시작 */
        static void Start()
        {
            Console.WriteLine("성적 프로그램 - Method");
        }

        /* 성적 입력 */
        static void Input(ref int kor, ref int mat, ref int eng)
        {
            Console.Write("국어 성적 입력 : ");
            kor = Int32.Parse(Console.ReadLine());

            Console.Write("수학 성적 입력 : ");
            mat = Int32.Parse(Console.ReadLine());

            Console.Write("영어 성적 입력 : ");
            eng = Int32.Parse(Console.ReadLine());
        }

        /* 입력한 성적의 합 */
        static int Total(int kor, int mat, int eng)
        {
            return kor + mat + eng;
        }

        /* 성적의 평균 */
        static void Average(int total, out float average)
        {
            average = (float)total / 3;
        }

        static void Main(string[] args)
        {
            int kor = 0;
            int eng = 0;
            int mat = 0;
            int total;
            float average;

            Start();
            Input(ref kor, ref eng, ref mat);
            total = Total(kor, mat, eng);
            Average(total, out average);

            Console.WriteLine("Total : {0} / Average : {1}", total, average);
        }
    }
}