Question

using java : Kenmore has contacted you to help write code to control their new line...

using java

: Kenmore has contacted you to help write code to control their new line of home appliances. Write the “Refrigerator” class that has tracks the temperature of the refrigerator and the amount of water remaining in the water dispenser (max is 100 ounces). Kenmore also needs you to create a constructor and methods to increase or decrease the temperature along with dispensing water (8 ounces at a time) and refilling the water tank from a connected water hose. (30


0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any problem with the code feel free to comment.

Program

class Refrigirator{
   //instance variables
   private double temperature;
   private double water;
  
   //constructor
   public Refrigirator(double temperature, double water) {
       this.temperature = temperature;
       this.water = water;
   }

   //getters method
   public double getTemperature() {
       return temperature;
   }

   public double getWater() {
       return water;
   }
  
   //increase and decrease temperature
   public void increaseTemperature() {
       temperature++;
   }
  
   public void decreaseTemperature() {
       temperature--;
   }
  
   //dispense and refill water
   public void dispenseWater() {
       if(water > 0 )
       water-=8;
       else
           System.out.println("Water container is empty");
      
   }
  
   public void refillWater() {
       if(water < 100)
           water+=30;
       else
           System.out.println("Water is full");
   }

   @Override
   public String toString() {
       return "Refrigirator [temperature=" + temperature + "C, water=" + water + "]";
   }
}

public class Test{//driver class running the program
   public static void main(String[] args) {
       Refrigirator samsung = new Refrigirator(5, 42); //temperature is in celcius
      
       System.out.println("Intial Refrigirator condition");
       System.out.println(samsung);
      
       System.out.println();
      
       samsung.increaseTemperature();
      
       samsung.refillWater();
      
       System.out.println("After increasing and refill");
       System.out.println(samsung);
   }
}

Output

<terminated> Test (1) [Java Application] C:\Program Files\Java\jre1.8.0 211\bin\javaw.exe (05-Dec-2019, 1:40:15 pm) Intial Re

Add a comment
Know the answer?
Add Answer to:
using java : Kenmore has contacted you to help write code to control their new line...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • A pmc has contacted you to help write code to control the security checkpoints for their...

    A pmc has contacted you to help write code to control the security checkpoints for their company. You must create a checkpoint class with hidden attributes (Authorized, guest, Unauthorized), two constructors (a default that sets all access level to false and an overloaded that sets authorized and unauthorized to false and guest to true for testing purposes) and a method that changes the access levell to the next in the sequence(authorized - guest - unauthorized) In java

  • In java code: Write a Temperature class that has two private instance variables: • degrees: a...

    In java code: Write a Temperature class that has two private instance variables: • degrees: a double that holds the temperature value • scale: a character either ‘C’ for Celsius or ‘F’ for Fahrenheit (either in uppercase or lowercase) The class should have (1) four constructor methods: one for each instance variable (assume zero degrees if no value is specified and assume Celsius if no scale is specified), one with two parameters for the two instance variables, and a no-argument...

  • Java Code Help! Code this: Calculate statistics. Write a class called Statistics that can calculate a...

    Java Code Help! Code this: Calculate statistics. Write a class called Statistics that can calculate a number of properties about an array of doubles. There should be separate static methods to calculate the min, the max, the mean, the median, the standard deviation (make sure to make use of your mean method to implement this), and the mode. For the mode, you can assume that the data set is not multimodal. This class should not have a main method. Write...

  • Write code in Java programming language. The ShoppingCart class will be composed with an array of...

    Write code in Java programming language. The ShoppingCart class will be composed with an array of Item objects. You do not need to implement the Item class for this question, only use it. Item has a getPrice() method that returns a float and a one-argument constructor that takes a float that specifies the price. The ShoppingCart class should have: Constructors: A no-argument and a single argument that takes an array of Items. Fields: • Items: an array of Item objects...

  • Note: Write the pseudocode separately and the source code separately in java using the loops method...

    Note: Write the pseudocode separately and the source code separately in java using the loops method according to the question. Please make sure there is no errors. Program 0 (Warm up): Gimme a cookie! In the early days of computing, you likely couldn't afford your own computer. Instead, you had to sit at a terminal - which was literally just a monochrome monitor and keyboard that was connected to a big mainframe machine (hidden somewhere in the building). When you...

  • Need Help Please Using Java Language Create a Code Write a class (and a client class...

    Need Help Please Using Java Language Create a Code Write a class (and a client class to test it) that encapsulates the evolution of the passwords of three students over four months. Your only instance variable should be a two-dimensional array of values representing the passwords. Dimension 1 represents the student and dimension 2 represents the month. (Since we are concerned about security, we are assuming that people change their password once a month; we only care about the value...

  • Can you help me to write a Java code for this: The program must satisfy the...

    Can you help me to write a Java code for this: The program must satisfy the following requirements: The program should ask the user the following information The site names for 6 locations (into an array) The cash donation for 6 locations (into an array) The food donations in pounds for 6 locations (into an array) Is there another test they want to process, meaning do they want to run the program again? Based on the input, the program will...

  • Draw the UML DIAGRAM ALSO PLEASE DRAW THE UML DIAGRAM.ALSO in java should use the program in java For this task you will create a Point3D class to represent a point that has coordinates in thr...

    Draw the UML DIAGRAM ALSO PLEASE DRAW THE UML DIAGRAM.ALSO in java should use the program in java For this task you will create a Point3D class to represent a point that has coordinates in three dimensions labeled x, y and z. You will then use the class to perform some calculations on an array of these points. You need to draw a UML diagram for the class (Point3D) and then implement the class The Point3D class will have the...

  • Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the...

    Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...

  • Needs Help with Java programming language For this assignment, you need to write a simulation program...

    Needs Help with Java programming language For this assignment, you need to write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: • delete the addfirst, addlast, and add(index) methods and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT