SHARE
TWEET

Repetition Assignment (PG. 5, Temp. Program Source Code)

MichaelMykhaylenko Jan 24th, 2020 (edited) 22 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. public class MyProgram
  3. {
  4.     public static void main(String[] args)
  5.     {
  6.         //Create objects for reading in data
  7.         Scanner in = new Scanner(System.in);
  8.         System.out.println("***   TEMPERATURE PROGRAM   ***");
  9.         System.out.println("Enter current temperature: ");
  10.         double temperature = in.nextDouble();
  11.         System.out.println("Temperature entered: " + temperature);
  12.             if (temperature <-100 || temperature >100) {
  13.                 System.out.println("Error: are you insane?");
  14.             }else{
  15.                 if (temperature <=-20) {
  16.                     System.out.println("Wear your parka!");
  17.                 } else if (temperature <=-10) {
  18.                     System.out.println("Wear your winter coat with hat and mittens!");
  19.                 } else if (temperature <=0) {
  20.                     System.out.println("Wear you winter coat!");
  21.                 } else if (temperature <=10) {
  22.                     System.out.println("Wear your spring coat!");
  23.                 } else{
  24.                     System.out.println("Wear your shorts!");
  25.             }
  26.         }
  27.     }
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top