#include
using namespace std;
int main(){
int S1_No, S2_No, S3_No;
int S1_Kor, S2_Kor, S3_Kor;
int S1_Math, S2_Math, S3_Math;
int S1_Eng, S2_Eng, S3_Eng;
float S1_Ave, S2_Ave, S3_Ave;
float TotalAve = 0.0f;
int NumberOfStudent = 0;
while(1)
{
cout << "\n--------- 메뉴 --------\n";
cout << "1. 학생 성적 추가\n";
cout << "2. 전체 성적 보기\n";
cout << "Q. 프로그램 종료 \n";
cout << "-------------------------\n\n";
cout << " 원하는 작업의 번호를 입력하세요 : ";
char select;
cin >> select;
switch(select)
{
case 1:
cout << "\n학생 성적 추가가 선택되었습니다.\n";
{
if (3 == NumberOfStudent)
{
cout << "\n더 이상 입력할 수 없습니다.\n";
break;
}
int Kor, Eng, Math;
cout << "국어 영어 수학 점수를 입력하세요 : ";
cin >> Kor >> Eng >> Math;
float Ave = float(Kor + Eng + Math) / 3.0f;
if (0 == NumberOfStudent)
{
S1_No = NumberOfStudent +1;
S1_Kor = Kor;
S1_Eng = Eng;
S1_Math = Math;
S1_Ave = Ave;
TotalAve = S1_Ave;
}
else if (1 == NumberOfStudent)
{
S2_No = NumberOfStudent +1;
S2_Kor = Kor;
S2_Eng = Eng;
S2_Math = Math;
S2_Ave = Ave;
TotalAve = (S1_Ave+S2_Ave)/2;}
else
{
S3_No = NumberOfStudent + 1;
S3_Kor = Kor;
S3_Eng = Eng;
S3_Math = Math;
S3_Ave = Ave;
TotalAve = (S1_Ave + S2_Ave + S3_Ave)/3;
}
NumberOfStudent++;
cout << "\n학생 성적이 올바르게 입력되었습니다.\n";
break;
}
case 2:
cout << "\n전체 성적 보기가 선택되었습니다.\n";
break;
{
case 2:
{
cout << "\n전체 성적 보기 \n";
cout << "학번 국어 영어 수학 평균\n";
for (int i = 0; i < NumberOfStudent; ++i)
{
if (0 == i)
{
cout << S1_No << " " << S1_Kor << " " << S1_Eng;
cout << " " << S1_Math << " " << S1_Ave << "\n";
}
else if ( 1 == i)
{
cout << S2_No << " " << S2_Kor << " " << S2_Eng;
cout << " " << S2_Math << " " << S2_Ave << "\n";
}
else
{
cout << S3_No<< " " << S3_Kor << " " << S3_Eng;
cout << " " << S3_Math << " " <
}
}
cout << "\n전체 평균 = " << TotalAve << "\n";
break;
}
case Q:
case q:
cout << "\n프로그램을 종료합니다.\n";
return 0;
default:
cout << "\n올바르지 않는 입력입니다.\n";
break;}}}
return 0;}
어떤식으로 어떻게 해야할지 잘 모르겠네요 ㅠ_ ㅠ