grodek118

Exam Score (if-else)

Sep 9th, 2022
1,102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         int score;
  8.  
  9.         Scanner keyboard = new Scanner(System.in);
  10.  
  11.         System.out.println("Enter your exam score");
  12.         score = keyboard.nextInt();
  13.  
  14.         if (score < 60) {
  15.             System.out.println("Your grade is F");
  16.         }
  17.         else {
  18.             if (score < 70) {
  19.                 System.out.println("Your grade is D");
  20.             }
  21.             else {
  22.                 if (score < 80) {
  23.                     System.out.println("Your grade is C");
  24.                 }
  25.                 else {
  26.                     if (score <90) {
  27.                         System.out.println("Your grade is B");
  28.                     }
  29.                     else {
  30.                         if (score >= 90) {
  31.                             System.out.println("Your grade is A");
  32.                         }
  33.                     }
  34.                 }
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment