StefanTobler

Lesson 12 Activity 3

Sep 25th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. /*
  2.  * Lesson 12 Coding Activity 3
  3.  * Test if a number input from the keyboard is a valid
  4.  * test score (between 0 and 100 inclusive).
  5.  *    
  6.  *     Sample Run 1
  7.  *         Enter a test score:
  8.  *         78.5
  9.  *         Valid
  10.  *
  11.  *        
  12.  *      Sample Run 2
  13.  *         Enter a test score:
  14.  *         179
  15.  *         Not Valid        
  16.  *
  17.  */
  18.  
  19.  
  20. import java.util.Scanner;
  21.  
  22. class Lesson_12_Activity_Three {
  23.     public static void main(String[] args)
  24.      {
  25.     Scanner scan = new Scanner(System.in);
  26.        
  27.        System.out.println("Enter a test score: ");
  28.        
  29.        double x = scan.nextDouble();
  30.        
  31.        if(x <= 100)
  32.        {  
  33.          System.out.println("Valid");
  34.        }
  35.        if(x > 100)
  36.        {  
  37.          System.out.println("Not Valid");
  38.        }
  39.        if(x < 0)
  40.        {  
  41.          System.out.println("Not Valid");
  42.        }
  43.     }
  44. }
Add Comment
Please, Sign In to add comment