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: 3921619 • 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

Question39.java

   import java.util.Scanner;
  
  
   public class Question39 {
  
       public static void main(String[] args) {
               Scanner scan = new Scanner(System.in);
               System.out.println("Enter temperature: ");
               int temp = scan.nextInt();
               if(temp >=76 && temp <=100){
                   outputHot(temp);
               }
               else if(temp >=0 && temp <=39){
                   outputCold(temp);
               }
               else if(temp >=40 && temp <=75){
                   outputJustRight(temp);
               }
               else{
                   System.out.println("Temperature outside range");
               }
       }
      
       public static void outputHot(int temp){
           System.out.println("Temperature "+temp+" Hot ");
       }
       public static void outputCold(int temp){
           System.out.println("Temperature "+temp+" Cold ");  
           }
       public static void outputJustRight(int temp){
           System.out.println("Temperature "+temp+" Just Right ");
       }
   }

Output:

Enter temperature:
45
Temperature 45 Just Right

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