StefanTobler

Lesson 13 Activity 6

Sep 25th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. /*
  2.  * Lesson 13 Coding Activity 6
  3.  * We are going to redo the last coding activity from Lesson 12,
  4.  * but this time it will also print out a message if the temperature is OK.
  5.  *
  6.  * You are running an experiment that involves hatching chicken eggs.
  7.  * Bird eggs are very sensitive to temperature and chickens' eggs will hatch between 99 and 102 degrees Fahrenheit.
  8.  *
  9.  * Write the code for the sensor that will be tracking the temperature.
  10.  * If the temperature falls below 99 or above 102 your code should print ÒWARNINGÓ otherwise ÒTemperature is OKÓ.
  11.  * The values 99 and 102 are considered to be included in the ok range and the input will be in doubles.
  12.  *
  13.  *
  14.  *     Sample Run 1
  15.  *         What is the temperature?
  16.  *         45.3
  17.  *         WARNING
  18.  *
  19.  *        
  20.  *      Sample Run 2
  21.  *         What is the temperature?
  22.  *         100    
  23.  *         Temperature is OK
  24.  *
  25.  */
  26.  
  27.  
  28. import java.util.Scanner;
  29.  
  30. class Lesson_13_Activity_Six {
  31.     public static void main(String[] args)
  32.      {
  33.        Scanner scan = new Scanner(System.in);
  34.        
  35.       System.out.println("What is the temperature?");
  36.        
  37.        double x = scan.nextDouble();
  38.        
  39.        if(x < 99)
  40.        {  
  41.          System.out.println("WARNING");
  42.        }
  43.        else if (x > 102)
  44.        {
  45.          System.out.println("WARNING");
  46.        }
  47.        else
  48.        {
  49.          System.out.println("Temperature is OK");
  50.        }
  51.     }
  52. }
Add Comment
Please, Sign In to add comment