Question

In: Computer Science

Creat a program that is part of a control system for a house. Create two Boolean...

Creat a program that is part of a control system for a house. Create two Boolean variables: doorUnLocked and lightOn. Set both to false. Create an int variable: currentTemp. Set the currentTemp value to 70 Create two more Boolean variables: heatOn and coolingOn. Set both of these values to false. Ask the user if they want to unlock the door, turn on the light and what value the temperature should be. If they want to unlock the door, set doorUnlocked to true. If they do not want to unlock the door, set the doorUnlocked value to false. If they want to turn on the light set lightOn to true. If they do not want to turn on the light set the lightOn to false. For the desired temperature value, if the desired value is the same as the currentTemp, do nothing. If the desired value is less than the currentTemp set coolingOn to true and heatOn to false. If the desired value is more than the currentTemp set heatOn to true and coolingOn to false. Display the state of the door (locked or unlocked), the state of the lights (on or off) and the desired temperature and the current temperature. Ask the user if they want to make changes. If they do, loop back and ask for all three values again. If no changes are desired, end the program.

Solutions

Expert Solution

Hi,

Program:

import java.util.Scanner;

//HCS class
public class HCS {
   //main method
   public static void main(String args[]) {

       //variables declaration
       boolean doorUnLocked = false;
       boolean lightOn = false;

       int currentTemp = 70;

       boolean heatOn = false;
       boolean coolingOn = false;

       System.out.println("\n**** WELCOME TO HOUSE CONTROL SYSTEM ****");

       Scanner sc = new Scanner(System.in);
       String ch = null;
       do {
           //get the input from user
           System.out.print("\nDo you want to unlock the door(y/n): ");
           String status = sc.next();

           //checking the conditions
           if (status.equalsIgnoreCase("y") || status.equalsIgnoreCase("yes"))
               doorUnLocked = true;
           else
               doorUnLocked = false;
          
           System.out.print("\nDo you want to turn on the ligh(y/n): ");
           status = sc.next();

           if (status.equalsIgnoreCase("y") || status.equalsIgnoreCase("yes"))
               lightOn = true;
           else
               lightOn = false;

           System.out.print("\nPlease enter your desired temperature: ");
           int temp = sc.nextInt();
           //checking the conditions
           if (temp < currentTemp) {
               coolingOn = true;
               heatOn = false;
           } else if (temp > currentTemp) {
               coolingOn = false;
               heatOn = true;
           } else {
               coolingOn = false;
               heatOn = false;
           }
           //displaying values
           System.out.println("\nIs door unLocked: " + doorUnLocked);
           System.out.println("Is light on: " + lightOn);

           System.out.println("Current temparature is: " + currentTemp);
           System.out.println("Desired temparature is: " + temp);

           System.out.println("Is Heat on: " + heatOn);
           System.out.println("Is Cool on: " + coolingOn);

           System.out.print("\nDo you want make more changes(y/n): ");
           ch = sc.next();

       } while (ch.equalsIgnoreCase("y"));

   }
}

Output Screenshots:


Related Solutions

how to creat a bank system application for Java?
how to creat a bank system application for Java?
Creat a linux assembly program that asks two scores from the user, specifically, the raw score...
Creat a linux assembly program that asks two scores from the user, specifically, the raw score as the first score and the total score as the second score. Store the digits in the EAX and EBX register, respectively. Given the formula raw score divided by total score times 50 and plus 50. Store the result in a memory location 'res' and finally display the result.
As part of its cost control program, Tracer Company uses a standard costing system for all...
As part of its cost control program, Tracer Company uses a standard costing system for all manufactured items. The standard cost for each item is established at the beginning of the fiscal year, and the standards are not revised until the beginning of the next fiscal year. Changes in costs, caused during the year by changes in direct materials or direct labor inputs or by changes in the manufacturing process, are recognized as they occur by the inclusion of planned...
Part A: Create a project with a Program class and write the following two methods (headers...
Part A: Create a project with a Program class and write the following two methods (headers provided) as described below: A Method, public static int InputValue(int min, int max), to input an integer number that is between (inclusive) the range of a lower bound and an upper bound. The method should accept the lower bound and the upper bound as two parameters and allow users to re-enter the number if the number is not in the range or a non-numeric...
"An aircraft control actuator is part of the flight control system that enables an airplane to...
"An aircraft control actuator is part of the flight control system that enables an airplane to fly. It is important that the actuators are reliable. Reliability can be defined as the probability a system is functioning, so it is a number between 0 and 1. One way to increase reliability of the actuator is to increase the torque. The reliability R as a function of the maximum torque T (in Newton-meters) is given by R(T)=0.91*exp(0.027T) where torque T is between...
"An aircraft control actuator is part of the flight control system that enables an airplane to...
"An aircraft control actuator is part of the flight control system that enables an airplane to fly. It is important that the actuators are reliable. Reliability can be defined as the probability a system is functioning, so it is a number between 0 and 1. One way to increase reliability of the actuator is to increase the torque. The reliability R as a function of the maximum torque T (in Newton-meters) is given by R(T)=0.91*exp(0.027T) where torque T is between...
An aircraft control actuator is part of the flight control system that enables an airplane to...
An aircraft control actuator is part of the flight control system that enables an airplane to fly. It is important that the actuators are reliable. Reliability can be defined as the probability a system is functioning, so it is a number between 0 and 1. One way to increase reliability of the actuator is to increase the torque. The reliability R as a function of the maximum torque T (in Newton-meters) is given by R(T)=0.91*exp(0.027T) where torque T is between...
Why do single - menber district tend to create a two part system in the governments...
Why do single - menber district tend to create a two part system in the governments that implement them? Why do Proportional representation systems lead to more numerous and more disciplined parties?
As part of the quality-control program for a catalyst manufacturing line, the raw materials (alumina and...
As part of the quality-control program for a catalyst manufacturing line, the raw materials (alumina and a binder) are tested for purity. The process requires that the purity of the alumina is to be 85%. A random sample from a recent shipment of alumina yielded the following results (in %):            93.2               87.0               92.1                      90.1               87.3               93.6 a) Test the requirements of the catalyst manufacturing line using the appropriate hypothesis test (assume a=0.05). b) Verify your result in part...
Create a Java program that asks a user to enter two file names. The program will...
Create a Java program that asks a user to enter two file names. The program will read in two files and do a matrix multiplication. Check to make sure the files exist. first input is the name of the first file and it has 2 (length) 4 5 6 7 Second input is the name of the second file and it has 2 (length) 6 7 8 9 try catch method
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT