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?
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...
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.
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?
how to creat Create a text file that contains a list of integer numbers separated by...
how to creat Create a text file that contains a list of integer numbers separated by comma (numbers.txt). E.g. 3, 7, 5, 1, 11, 8,2, 6 2- how to Write a python program (minMax.py) to read the file numbers.txt and find the largest and smallest numbers in the file. (without using use min(), max()). calculate the average and output the results. 3-Use python file i/o, write a python program (fileCopy.py) that makes a copy of minMax.py (Read contents of minMax.cp...
I have to create a program that: define class cust(I already did this part) create an...
I have to create a program that: define class cust(I already did this part) create an array of cust (size 10)to hold the data of the class. (done) read the date from a file(everything from the class - already done) call a function print cust(this function will print all the data in table format)....first, last, state, sales history(0,1,2), units Read the data from a file (you may break up the strings and numeric values any way you choose (separate lines...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT