In: Computer Science
Program using java
Take user input and give corresponding output.
A user is considering different options of operating air conditioning.
Depending on room temperature (here, room temperature is given by user), this program should give different instructions.
There are three scenarios.
- If temperature is above 90, the program should output “cooling”.
-If the temperature is below 70, the program should output “heating”.
-Otherwise, the program should output “stopped”.
For example, if user enters “95”, this is how the program should look like:
Please enter room temperature: 95
Air conditioning is cooling.
Code is Given Below:
======================
import java.util.Scanner;
public class Temperature {
   public static void main(String[] args) {
       //creating Scanner object to get
input from user
       Scanner sc=new
Scanner(System.in);
       //asking user for input
       System.out.print("Please enter room
temperature: ");
       double t=sc.nextDouble();
       //checking condition and printing
output
       if(t>90) {
          
System.out.println("Air conditioning is cooling.");
       }
       else if(t<70) {
          
System.out.println("Air conditioning is heating.");
       }
       else {
          
System.out.println("Air conditioning is stopped.");
       }
      
   }
}
Output:
==============

Code Snapshot:
==================
