Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a java program called Question39 that does the following: Gets input for t

ID: 3577027 • Letter: W

Question

Write a java program called Question39 that does the following:

Gets input for temperature

Utilizing a branching statement:

If temperature is 76-100, call method outputHot passing the temperature input as an argument.

If temperature is 0-39, call method outputCold passing the temperature input as an argument.

If temperature is 40 to 75, call method outputJustRight passing the temperature input as an argument.

If temperature is outside these ranges, output “Temperature outside range” to the screen.

Be precise, import modules, include comments, prologue, etc. as needed.

Explanation / Answer


// Temperature.java
import java.util.*;
import java.util.Scanner;

public class Temperature
{
  
   public static void outputHot( double temp)
   {
       System.out.println("Too Hot");
   }

   public static void outputCold( double temp)
   {
       System.out.println("Too Cold");
   }

   public static void outputJustRight( double temp)
   {
       System.out.println("Just Right");
   }


   public static void main(String[] args)
   {
       Scanner sc=new Scanner(System.in);

        System.out.print("Input temperature: ");
        double temp = sc.nextInt();

        if(temp >=76 && temp <= 100 )
            outputHot(temp);
        else if(temp <= 75 && temp >= 40)
            outputJustRight(temp);
        else if(temp >= 0 && temp <= 39)
            outputCold(temp);
        else
            System.out.println("Temperature outside range");
   }
}

/*
output:

Input temperature: 99
Too Hot

Input temperature: 23
Too Cold

Input temperature: 67
Just Right

Input temperature: -1
Temperature outside range


*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote