Answered step by step
Verified Expert Solution
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.cisspputyourusernamehere;
File: Temperature.java
Requirements:
Add two new methods:
incrementTemp
decrementTemp
that increment and decrement the current temperature value
by one degree respectively
Add a method:
changeTemp double t that adds t to the current temperature
Add a main method to this class
In the main method:
create two instances of the Temperature
object each with a different temperature
Call the getTemp method in each of the temperature objects
and print a message with the result to the users screen Console
Call the incrementTemp decrementTemp and changeTempt
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 putyournamehere
public class Temperature
private double currentTemp;
setTemp sets the temperature to the given value
@param t the given value
public void setTempdouble 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started