Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package edu.buffalostate.cis 4 2 5 . sp 2 4 . put - your - username - here; / * * File: Temperature.java * * Requirements:

package edu.buffalostate.cis425.sp24.put-your-username-here;
/** File: Temperature.java
*
* Requirements:
*
*1) Add two new methods:
* incrementTemp()
* decrementTemp()
* that increment and decrement the current temperature value
* by one degree respectively
*2) Add a method:
* changeTemp( double t ) that adds t to the current temperature
*3) Add a main() method to this class
*4) In the main method:
* create two instances of the Temperature
* object each with a different temperature
*5) Call the getTemp() method in each of the temperature objects
* and print a message with the result to the users screen (Console)
*6) Call the incrementTemp(), decrementTemp() and changeTemp(t)
* methods several times from the main()
*(use getTemp() to see if the temperature did change)
* Remember that there should not be any print statements in the
* Temperature class - The print statements display the temperature
* changes should be in the main() method.
*
* Description: This class stores the current temperature.
* It contains access methods to set and get the temperature.
*
*/
/**
*
* @author put-your-name-here
*
*/
public class Temperature
{
private double currentTemp;
/*** setTemp() sets the temperature to the given value
* @param t -- the given value
*/
public void setTemp(double t)
{
currentTemp = t;
}
/**
*
* getTemp() returns the current temperature
*
*/
public double getTemp()
{
return currentTemp;
}
/**
* incrementTemp() returns the (new) current temperature
*/
/* put code here */
/*
*
* decrementTemp() returns the (new) current temperature
*
*/
/* put code here */
/*
*
* changeTemp( double t ) adds t to current temperature and
* then returns the (new) temperature
*
*/
/* put code here */
}// Temperature

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions