import java.util.*;
import java.lang.*;
import java.io.*;
/*class Main {
public static void main(String[] args) {
buy(28);
buy(15);
}
public static void buy(int age) {
if(age >= 19) {
System.out.printf("%d, 캔맥주 구매 가능\n", age);}
else {
System.out.printf("%d, 캔맥주 구매 불가\n", age);}
}
}*/
/*
class Main {
public static void main(String[] args) {
buy(28);
buy(30);
buy(15);
}
/*
public static void main(String[] args) {
// 사용자 입력을 받기 위한 Scanner 객체 생성
Scanner scanner = new Scanner(System.in);
System.out.print("나이를 입력하세요: ");
// 사용자가 입력한 정수를 age 변수에 저장
int age = scanner.nextInt();
System.out.println();
// 입력받은 나이로 buy 메서드 호출
buy(age);
// Scanner 자원 반납
scanner.close();
}
*/
public static void buy(int age) {
if (age >= 19 && age != 30) {
System.out.printf("%d, 캔맥주 구매 가능\n", age);
} else if (age == 30) {
System.out.printf("%d, 한판입니다.\n", age);
} else {
System.out.printf("%d, 캔맥주 구매 불가\n", age);
}
}
}
*/
class Main {
public static void main(String[] args) {
System.out.printf(28점의 학점 : %s, getGrade(28));
System.out.printf(70점의 학점 : %s, getGrade(70));
System.out.printf(70점의 학점 : %s, getGrade(80));
System.out.printf(100점의 학점 : %s, getGrade(100));
}
public static void getGrade(int score) {
String grade = "F"
if (score >=90) grade = "A"; else if (score >=80) grade = "B"; else if (score >=70) grade = "C";
return grade;
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: