Java Program:
package temperatureclassdriver;
//Temperature Class
//Class definition
class Temperature {
//Data memebers
private double val;
private char scale;
//Methods
//Default constructor
public Temperature() {
val = 0;
scale = 'C';
}
//1-Arg
public Temperature(double val) {
this.val = val;
this.scale = 'C';
}
//1-Arg
public Temperature(char scale) {
this.val = 0;
this.scale =
scale;
}
//2-Arg
public Temperature(double val, char scale)
{
this.val = val;
this.scale =
scale;
}
//Accessor method
double getTemp_Celsius() {
//If its is in
Celsius
if(scale == 'C') {
return val;
}
double mVal;
mVal = ( 1.8 * val ) +
32.0;
//Converting to
Celsius
return mVal;
}
//Accessor method
double getTemp_Fahrenheit() {
//If its is in
Fahrenheit
if(scale == 'F') {
return val;
}
double mval;
//Applying
conversion
mval = (double)((5/9.0)
* (val - 32));
//Converting to
Celsius
return mval;
}
//Setter method
public void setVal(double val) {
this.val = val;
}
//Setter method
public void setScale(char scale) {
this.scale =
scale;
}
//Setter Method
public void setValues(double val, char scale)
{
this.val = val;
this.scale =
scale;
}
//Compares two Objects
public boolean equals(Temperature obj) {
//Comparing scales
if
(this.getTemp_Fahrenheit() != obj.getTemp_Fahrenheit()) {
return false;
}
return true;
}
//Compares to Objects
public boolean isGreater(Temperature obj)
{
//Comparing scales
if
(this.getTemp_Celsius() > obj.getTemp_Celsius()) {
return true;
}
return false;
}
//Compares to Objects
public boolean isLesser(Temperature obj) {
//Comparing scales
if
(this.getTemp_Celsius() < obj.getTemp_Celsius()) {
return true;
}
return false;
}
}
//Class definition
public class TemperatureClassDriver {
//Main method
public static void main(String[] args) {
//Testing Temperature
class
Temperature t1 = new
Temperature(32, 'C');
Temperature t2 = new
Temperature(20);
Temperature t3 = new
Temperature('F');
//Comparing temperatures
t1 and t2
if(t1.isGreater(t2))
{
System.out.println(" Temperature 1 is greater than Temperature 2
");
}
else {
System.out.println(" Temperature 1 is less than Temperature 2
");
}
//Comparing temperatures
t2 and t3
if(t2.isLesser(t3))
{
System.out.println(" Temperature 2 is less than Temperature 3
");
}
else {
System.out.println(" Temperature 2 is greater than Temperature 3
");
}
//Creating 6 temperature
objects
Temperature t11 = new
Temperature(0, 'C');
Temperature t12 = new
Temperature(32.0, 'F');
Temperature t13 = new
Temperature(-40.0, 'C');
Temperature t14 = new
Temperature(-40.0, 'F');
Temperature t15 = new
Temperature(100.0, 'C');
Temperature t16 = new
Temperature(212.0, 'F');
//Comparing
objects
if(t11.equals(t12))
{
System.out.println(" Both are same ");
}
else {
System.out.println(" Both are not same ");
}
if(t13.equals(t14))
{
System.out.println(" Both are same ");
}
else {
System.out.println(" Both are not same ");
}
if(t15.equals(t14))
{
System.out.println(" Both are same ");
}
else {
System.out.println(" Both are not same ");
}
}
}
________________________________________________________________________________________
Sample Run:

Java program Write a Temperature class that represents temperatures in degrees in both Celsius and Fahrenheit....
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 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 - 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 constructor (set...
A breakdown of the problem is as follows: Class name: Temperature Instance variables: temp (double) and tempScale (char; either ‘C’ or ‘F’) Constructor methods: Temperature() – sets temp to 0 Celsius Temperature(double initialTemp) – sets temp Temperature(char tempType) – sets tempScale to ‘C’ or ‘F’) Temperature(double initialTemp, char tempType) -- sets temp and tempScale to ‘C’ or ‘F’) Accessor methods: getTemp – returns value of temp for the object getTempScale– returns temperature scale (‘C’ or...
Question: Fahrenheit To Celsius Temperature Converter GUI Assignment Write A GUI To... java Fahrenholt to Celsius Temperature Converter GUI Assignment Write a Gul to convert Fahrenheit temperatures to Celsius temperatures and has the following appearance: Com Convert It must include the following foatures • The frame we must say 'Fahrenheit to Celsius Temperature Converter • A border layout will be used for the GUI • The JLabelite of the GUI wil suy Fahrerholt to Celsius Temperature Converter and be in...
For this assignment you will create a program converting Fahrenheit temperatures to Celsius temperatures. The formula for converting a temperature from Celsius to Fahrenheit is: F = C x 1.8 + 32, where F is the Fahrenheit temperature and C is the Celsius temperature. Write a function named Fahrenheit that accepts a Celsius temperature as an argument and returns the temperature converted to Fahrenheit. Demonstrate the function by accepting a Celsius temperature from a user and displaying the temperature converted...
In Python, write a program that converts Celsius temperatures to Fahrenheit temperatures. The formula is as follows: F=(9/5)C+32 The program should ask the user to enter a temperature in Celsius, then display the temperature converted to Fahrenheit.
c++ please
2. (50 points) Create a Temperature class that internally stores a temperature in degrees Kelvin as a double. Create mutator functions named setTempKelvin, setTempFahrenheit, and set TempCelsius that take an input temperature in the specified temperature scale (i.e. Kelvin, Fahrenheit, and Celsius, respectively), and convert the temperature to Kelvin, and store that temperature in the class member private variable (only in Kelvin, no other scales). Also, create functions that return the stored temperature in degrees Kelvin, Fahrenheit, or...
IN JAVA…Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user should be able to enter a Celsius temperature, click a button, and then see the equiva-lent Fahrenheit temperature. Use the following formula to make the conversion: F = (9/5)C + 32 F is the Fahrenheit temperature and C is the Celsius temperature. Instead of only converting from Celsius to Fahrenheit, also convert from Fahrenheit to Celsius depending on the user's choice. Some hints: Use JTextField and...
Write a program that converts Celsius temperatures to Fahrenheit temperatures. The formula is as follows: F=95C+32 The program should ask the user to enter a temperature in Celsius, and then display the temperature converted to Fahrenheit. I'm doing this on Python.
(in python) Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user s... Write a GUI application that converts Celsius temperatures to Fahrenheit temperatures. The user should be able to enter a Celsius temperature, click a button, and then see the equivalent Fahrenheit temperature. Use the following formula to make the conversion ( F=9/5 C + 32) where F is the Fahrenheit temperature and C is the Celsius temperature