using System;
using System.Collections.Generic;
public class StudentList
{
public int tempNum { get; set; }
public int tempEnglish { get; set; }
public int tempJapen { get; set; }
public int tempSum { get; set; }
public int tempAverage { get; set; }
public int tempGC { get; set; }
}
public class 학생정보
{
public static void Main()
{
List<StudentList> lst = new List<StudentList>();
string tempNum;
string tempEnglish;
string tempJapen;
string btn = "n";
bool flag = false;
do
{
StudentList sc = new StudentList();
Console.Write("번호를입력 : ");
tempNum = Console.ReadLine();
if (Convert.ToInt32(tempNum) > 9)
{
Console.WriteLine("학생번호는 1의자리숫자 입니다");
return;
}
else
{
sc.tempNum = Convert.ToInt32(tempNum);
}
Console.Write("영어점수입력 : ");
tempEnglish = Console.ReadLine();
if (Convert.ToInt32(tempEnglish) < 0 || Convert.ToInt32(tempEnglish) > 100)
{
Console.WriteLine("점수는 0초과, 100이하 이어야합니다");
return;
}
else
{
sc.tempEnglish = Convert.ToInt32(tempEnglish);
}
Console.Write("일본어점수입력 : ");
tempJapen = Console.ReadLine();
if (Convert.ToInt32(tempJapen) < 0 || Convert.ToInt32(tempJapen) > 100)
{
Console.WriteLine("점수는 0초과, 100이하 이어야합니다");
return;
}
else
{
sc.tempJapen = Convert.ToInt32(tempJapen);
}
if (flag == false)
{
lst.Add(sc);
flag = true;
}
else
{
for (int i = 0; i < lst.Count; i++)
{
if (lst[i].tempNum == sc.tempNum)
{
Console.WriteLine("{0}{1}{2}", lst[i].tempNum, sc.tempNum,lst.Count);
Console.WriteLine("동일한학생번호가있어요");
return;
}
}
lst.Add(sc);
}
Console.WriteLine("더입력할까?? (y)");
btn = Console.ReadLine();
} while (btn == "y");
for (int i = 0; i < lst.Count; i++)
{
lst[i].tempSum = lst[i].tempEnglish + lst[i].tempJapen;
lst[i].tempSum = lst[i].tempSum / 2;
switch (lst[i].tempGC / 10)
{
case 9: lst[i].tempGC = 'A'; break;
case 8: lst[i].tempGC = 'B'; break;
case 7: lst[i].tempGC = 'C'; break;
case 6: lst[i].tempGC = 'D'; break;
default: lst[i].tempGC = 'F';
break;
}
}
for (int i = 0; i < lst.Count; i++)
{
Console.WriteLine("{0}번학생의 영어점수는 : {1}, 일어점수는 : {2}, 총점은 : {3}, 평균은 : {4}, 등급은 : {5}", lst[i].tempNum, lst[i].tempEnglish, lst[i].tempJapen, lst[i].tempSum, lst[i].tempAverage, lst[i].tempGC);
}
}
}
|