Advertisement
MichaelMykhaylenko

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

Jan 24th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement