728x90
반응형
SMALL

import java.util.Scanner; // 사용자 입력 Scanner

public class dfhdfh {
public static void main(String[] args) {
int kor, math, eng;
float ave;

Scanner scan=new Scanner(System.in);
System.out.println("국어 점수 영어점수 수학점수 입력 :");
kor = scan.nextInt(); // 국어 사용자 입력
eng = scan.nextInt(); // 영어 사용자 입력
math = scan.nextInt(); // 수학 사용자 입력
int total=kor+eng+math; // 평균 = 국어 + 영어 + 수학
double avg=total/3.0;

char score = 'A';
ave = total/3;
System.out.println("평균은 "+ave+"입니다");
if(ave>=90 && ave<=100) // 점수가 90점 이상 100점 이하일 때
{
score='A';
}
if(ave>=80 && ave<90) // 점수가 80점 이상 90점 미만일 때
{
score='B';
}
if(ave>=70 && ave<80) // 점수가 70점 이상 80점 미만일 때
{
score='C';
}
if(ave>=60 && ave<70) // 점수가 60점 이상 70점 미만일 때
{
score='D';
}
if (ave<60) // 이외의 점수는 F처리
{
score='F';
}

System.out.println("총점 "+total);
System.out.printf("평균:%.2f%n",avg);
System.out.println("학점:"+score);

}
}

728x90
반응형
LIST

+ Recent posts