1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
NeX [460]
3 years ago
10

Suppose there is a class AirConditioner. The class supports the following behaviors: turning the air conditioner on and off. The

following methods are provided for these behaviors: turn_on and turn_off. Both methods accept no arguments and return no value.
"There is a reference variable my_ac to an object of this class, which has already been created. There is also a variable status, which has already been initialized which refers to a bool. Invoke a method of this object using the reference variable, asking the object to tell whether the air conditioner is on or off, and store the result in status."
Computers and Technology
1 answer:
Ksenya-84 [330]3 years ago
5 0

Answer:

Firstly, create an AirConditioner class inside a file named as AirConditioner.java. This is important to make sure the class name match with the file name.

  1. public class AirConditioner {
  2.    private boolean status = false;
  3.    public void turn_on()
  4.    {
  5.        this.status = true;
  6.    }
  7.    public void turn_off()
  8.    {
  9.        this.status = false;
  10.    }
  11.    public boolean getStatus()
  12.    {
  13.        return this.status;
  14.    }
  15. }

Next, create another file named as Main.java. This is where we are going to include a Main method to create an object of AirConditioner class and get the air conditioner status. The codes are as follows:

  1. public class Main {
  2.    public static void main(String[] args) {
  3.        AirConditioner my_ac= new AirConditioner();
  4.        boolean status;
  5.        my_ac.turn_on();
  6.        status = my_ac.getStatus();
  7.        System.out.println(status);
  8.    }
  9. }

Explanation:

The codes presented above are written based on the question requirements.

<u>AirConditioner.java</u>

Line 1:

  • Create an AirConditioner  class

Line 3:

  • A property status is defined. This is important to track the status of an AirConditioner object.

Line 5 -8 and Line 10 -13:

  • Create two required methods turn_on() and turn_off(). Both of them accept no arguments and return no value.
  • The only job done by this two methods is to change the status property to either true (on) or false (off).

Line 15 - 18:

  • The getStatus() method is to return the current status of the AirConditioner object to the Main method in main.java.

<u>Main.java</u>

Line 5-6:

  • Within the Main method, create an object of AirConditioner and assign it to a reference variable, my_ac
  • Create the status variable as a boolean variable.

Line 8:

  • Use reference variable my_ac to invoke turn_on() method to change the status of the AirConditioner object to true
  • Use the same reference variable my_ac to invoke getStatus() method to get the current satus of the AirConditioner object and assign it to the status variable.

Line 11:

  • Print the status of AirConditioner Object in terminal
You might be interested in
Which ribbon tab is not a default in Outlook 2016's main interface?
IRISSAK [1]

Answer:

view

Explanation:

i just know it

8 0
3 years ago
Read 2 more answers
Complete the do-while loop to output every number form 0 to countLimit using printVal. Assume the user will only input a positiv
elena-s [515]

Answer:

PART ONE

  1. import java.util.Scanner;
  2. public class CountToLimit {
  3.    public static void main(String[] args) {
  4.        Scanner scnr = new Scanner(System.in);
  5.        int countLimit = 0;
  6.        int printVal = 0;
  7.        // Get user input
  8.        System.out.println("Enter Count Limit");
  9.        countLimit = scnr.nextInt();
  10.        do {
  11.            System.out.print(printVal + " ");
  12.            printVal = printVal + 1;
  13.        } while ( printVal<=countLimit );
  14.        System.out.println("");
  15.        return;
  16.    }
  17. }

PART TWO

  1. import java.util.Scanner;
  2. public class NumberPrompt {
  3.    public static void main (String [] args) {
  4.        Scanner scnr = new Scanner(System.in);
  5.        System.out.print("Your number < 100: ");
  6.       int  userInput = scnr.nextInt();
  7.      do {
  8.           System.out.print("Your number < 100: ");
  9.           userInput = scnr.nextInt();
  10.       }while (userInput>=100);
  11.        System.out.println("Your number < 100 is: " + userInput);
  12.        return;
  13.    }
  14. }

Explanation:

In Part one of the question, The condition for the do...while loop had to be stated this is stated on line 14

In part 2, A do....while loop that will repeatedly prompt user to enter a number less than 100 is created. from line 7 to line 10

7 0
3 years ago
Abusive behavior, which involves the use of an electronic communications device, that is degrading, humiliating, hurtful, insult
BARSIC [14]

B because this words degrading, humiliating, hurtful, insulting, intimidating, malicious, or otherwise offensive to an individual or group of individuals causing substantial emotional distress

7 0
3 years ago
Application area of word processor?​
kompoz [17]

Answer:

  1. Typing, editing,and printing different types of document .
  2. Formatting text, paragraph , pages for making attractive document .
  3. Checking spelling and grammar of document for making it error free.
  4. Inserting and editing pictures , objects, etc.
  5. Adding watermark , charts , quick flip, etc.
7 0
3 years ago
Read 2 more answers
Which statements describe the use of styles in Word? Check all that apply.
algol [13]

Answer:

can be used to make word docments look the same

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • )1-bit sign, 8-bit exponent, 23-bit fraction and a bias of127 is used for ___________ Binary Floating PointRepresentation
    11·1 answer
  • How does microchip work
    12·1 answer
  • In the lan protocol architecture the _________ layer is responsible for detecting errors and discarding any frames that are in e
    13·1 answer
  • on average, someone with a bachelor’s degree is estimated to earn _______ times more than someone with a high school diploma
    13·1 answer
  • give your opinion on if you would trust your accounts with an online bank. Explain why or why not. MANY people do not. MANY peop
    14·2 answers
  • Which social media post indicates your home may be unattended?
    10·1 answer
  • what are Include the data on usage you gather from your interactions with friends or by listening to people on the radio or on T
    7·1 answer
  • A ________ is a material deficiency, or combination of significant deficiencies, that results in more than a remote likelihood t
    6·1 answer
  • A ___________ is a variable used to pass information to a method.
    11·2 answers
  • The new software analyzes sales conversion per sales in a way intended to increase sales success. what is the first thing you mu
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!