#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)
{
int test = 0;
int attendance = 0;
int report = 0;
int student = 0;
int attempt = 0;
for (student = 0; student < 10; student++)
{
while (attempt < 3)
{
if (!test)
{
printf("시험 성적을 입력하세요: ");
scanf("%d", &test);
if (test > 100 || test < 0)
{
printf("성적은 0~100 사이 정수로 입력하세요!\n");
attempt++;
test = 0;
continue;
}
attempt = 0;
}
if (!report)
{
printf("과제 성적을 입력하세요:");
scanf("%d", &report);
if (report > 100 || report < 0)
{
printf("성적은 0~100 사이 정수로 입력하세요!\n");
attempt++;
report = 0;
continue;
}
attempt = 0;
}
if (!attendance)
{
printf("출석 성적을 입력하세요:");
scanf("%d", &attendance);
if (attendance < 0 || attendance > 45)
{
printf("출석 성적은 0~45사이 정수로 입력하세요!\n");
attempt++;
attendance = 0;
continue;
}
attempt = 0;
break;
}
}
if (attempt == 3)
{
printf("입력된 값 오류로 프로그램을 종료함\n");
return 0;
}
float sum = (float)(test + report + attendance);
float percent = sum / 245 * 100;
if (attendance < 30)
printf("학점:F\n");
else if (percent >= 90.5 && percent <= 100)
printf("학점:A+\n");
else if (percent >= 80.5 && percent <= 90.49)
printf("학점:A\n");
else if (percent >= 70.5 && percent <= 80.49)
printf("학점:B+\n");
else if (percent >= 60.5 && percent <= 70.49)
printf("학점:B\n");
else if (percent >= 50.5 && percent <= 60.49)
printf("학점:C+\n");
else if (percent >= 40.5 && percent <= 50.49)
printf("학점:C\n");
else if (percent >= 30.5 && percent <= 40.49)
printf("학점:D+\n");
else if (percent >= 20.5 && percent <= 30.49)
printf("학점:D\n");
else
printf("학점:F\n");
printf("\n");
test = 0;
report = 0;
attendance = 0;
attempt = 0;
}
return 0;
}
오른쪽 정렬 ㅅㅂ
소수점만 아니면 ㅈㄴ 간단하게 줄일 수 있는데..
제발 vsc에서 복사해서 붙여넣어 - dc App
이걸 지금 읽으라고... ㅍㄷㅍㄷ - dc App