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
solong [7]
3 years ago
8

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 office_a_c of type AirConditioner. Create a new object of type AirConditioner using the office_a_c reference variable. After that, turn the air conditioner on using the reference to the new object.
Computers and Technology
1 answer:
Sunny_sXe [5.5K]3 years ago
8 0

Answer:

The code is given in the explanation section

Explanation:

//Class Airconditioner

public class AirConditioner {

   private boolean turnOnOff;

//The Constructor

   public AirConditioner(boolean turnOnOff) {

       this.turnOnOff = turnOnOff;

   }

//method turn_on

   public void turn_on(){

       this.turnOnOff = true;

   }

//method turn_off

   public void turn_off( ){

       this.turnOnOff = false;

   }

}

// A new class to test the airconditional class

class AircondionTest{

   public static void main(String[] args) {

//Creating an object of the Aircondional class

       AirConditioner office_a_c = new AirConditioner(false);

//Using the reference varible to call method turn_on      

office_a_c.turn_on();

   }

}

You might be interested in
Design a class named QuadraticEquation for a quadratic equation ax^2+bx+x=0. The class contains: **private data fields a, b, and
LenaWriter [7]

Answer:

<em>C++</em>

///////////////////////////////////////////////////////////////////////////////////////////

#include <iostream>

using namespace std;

//////////////////////////////////////////////////////////////////

class QuadraticEquation {

   int a, b, c;

   

public:

   QuadraticEquation(int a, int b, int c) {

       this->a = a;

       this->b = b;

       this->c = c;

   }

   ////////////////////////////////////////

   int getA() {

       return a;

   }

   

   int getB() {

       return b;

   }

   

   int getC() {

       return c;

   }

   ////////////////////////////////////////

   // returns the discriminant, which is b2-4ac

   int getDiscriminant() {

       return (b*2)-(4*a*c);

   }

   

   int getRoot1() {

       if (getDiscriminant() < 0)

           return 0;

       else {

           // Please specify how to calculate the two roots.

           return 1;

       }

   }

   

   int getRoot2() {

       if (getDiscriminant() < 0)

           return 0;

       else {

           // Please specify how to calculate the two roots.

           return -1;

       }

   }

};

//////////////////////////////////////////////////////////////////

int main() {

   return 0;

}

4 0
3 years ago
Suppose that, even unrealistically, we are to search a list of 700 million items using Binary Search, Recursive (Algorithm 2.1).
damaskus [11]

Answer:

There is also an attachment below

Explanation:

Since we are talking about binary search, let's assume that the items are sorted according to some criteria.

Time complexity of binary search is O(logN) in worst case, best case and average case as well. That means it can search for an item in Log N time where N is size of the input. Here problem talks about the item not getting found. So, this is a worst case scenario. Even in this case, binary search runs in O(logN) time.

N = 700000000.

So, number of comparisions can be log(N) = 29.3 = 29.

So, in the worst case it does comparisions 29 times

7 0
3 years ago
Suppose that a machine with a 5-stage pipeline uses branch prediction. 15% of the instructions for a given test program are bran
zhenek [66]

Answer:

solution attached below

Explanation:

3 0
3 years ago
Can you help me solve this challenging activity?
diamong [38]

Answer:

user_age = int(input())

if user_age > 17 and user_age != 25:

   print("Eligible")

else:

   print("Not eligible")

Explanation:

3 0
1 year ago
Write a program that prompts the user to input an integer and then outputs both the individual digits of the number and the sum
otez555 [7]

Answer:

Explanation:

#Using python to create the list

#first we create an empty list to store our numbers.

import math

data = []

x = 0

InputSum = 0

NumInput=int(input("how many number do you want to add"))

while x <=(NumInput):

   Input=int(input("Enter the numbers here"))

   data.append(Input)

   x = x+1

   InputSum = InputSum + Input  #this is to add the numbers entered

print("The number you entered are ")

print(*data)  #this print the numbers entered

print("The sum of the numbers is", InputSum)

3 0
3 years ago
Other questions:
  • Give 5 uses of software and hardware.
    15·1 answer
  • // This pseudocode should create a report that contains an
    14·1 answer
  • What was the major sign that lead Professor Shiller to predict the crash of the housing market​
    6·1 answer
  • Match each language to its use.
    7·1 answer
  • If your computer won't connect to the internet, which of these is most likely to be the problem?
    8·1 answer
  • An acronym is a word formed by taking the first letters of the words in a phrase and making a word from them. For example, AGH i
    10·1 answer
  • I have a question. This question will probably be deleted, but why do moderators keep deleting my answers when they are legitima
    13·1 answer
  • If I am working in a document and wish to follow a hyperlink, what should I do?
    7·1 answer
  • An agile team has which two characteristics? (choose two. ).
    10·1 answer
  • Which image file format is an uncompressed raster file which may contain different depths of color depths per pixel, or may be s
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!