import java.util.Scanner; เรียกใช้ค่า Scanner
public class Main {
public static void main(String[] args) {
int intScoer; ประกาศตัวแปรชนิดเต็ม intScore
Scanner str = new Scanner(System.in); ประกาศตัวแปร str เพื่อเรียกใช้ Scanner
System.out.print("Enter Score : "); แสดงข้อความ Enter Score :
intScore = str.nextInt(); รับข้อมูลจำนวนเต็ม เก็บไว้ในตัวแปร intScore
if (intScore > 79) ตรวจสอบเงื่อนไขค่าของตัวแปร intScore มากกว่า 79 หรือไม่
{
System.out.printIn("\nMy Grade : A");
}
else if (intScore > 69) ตรวจสอบเงื่อนไขว่ามากกว่า 69 หรือไม่ ถ้าเป็นจริงทำงาน
{ ในชุดคำสั่ง else if
System.out.printIn("\nMy Grade : B"); แสดงข้อความ
}
else if ((intScore > 59)
{
System.out.printIn("\nMy Grade : C");
}
else if ((intScore > 49)
{
System.out.printIn("\nMy Grade : D");
}
else
{
System.out.printIn("\nMy Grade : F");
}
}
}
ทำไม Run ไม่ได้?
ตอบลบ