Write a java program called Question39 that does the followi

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.

Solution

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

Write a java program called Question39 that does the following: Gets input for temperature Utilizing a branching statement: If temperature is 76-100, call metho

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site