StefanTobler

Lesson 13 Activity 4

Sep 25th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. /*
  2.  * Lesson 13 Coding Activity 4
  3.  * Input an integer grade from the keyboard and translate it to a letter grade.
  4.  * For example, if a user enters 4, print "A", and if they enter 0 print "F."
  5.  * You can assume that an integer between 0 and 4 will be input.
  6.  */
  7.  
  8.  
  9. import java.util.Scanner;
  10.  
  11. class Lesson_13_Activity_Four {
  12.     public static void main(String[] args)
  13.      {
  14.        Scanner scan = new Scanner(System.in);
  15.        
  16.        System.out.println("Please enter a grade:");
  17.        
  18.        int x = scan.nextInt();
  19.        
  20.        if(x == 4)
  21.        {  
  22.          System.out.println("A");
  23.        }
  24.        else if (x == 3)
  25.        {
  26.          System.out.println("B");
  27.        }
  28.        else if (x == 2)
  29.        {
  30.          System.out.println("C");
  31.        }
  32.        else if (x == 1)
  33.        {
  34.          System.out.println("D");
  35.        }
  36.        else
  37.        {
  38.          System.out.println("F");
  39.        }
  40.     }
  41. }
Add Comment
Please, Sign In to add comment