Answered Essay: 1 Temperature Class Write a Temperature class that has two instance variables: a temperature value (a floating-p

1 Temperature Class Write a Temperature class that has two instance variables: a temperature value (a floating-point number) and a character for the scale, either C for Celsius or F for Fahrenheit. The class should have four constructor methods: one for each instance variable (assume zero degrees if no value is specified and Celsius if no scale is specified), one with two parameters for the two instance variables, and a no-argument constructor (set to zero degrees Celsius). Include the following: • (1) two accessor methods to return the temperature–one to return the degrees Celsius, the other to return the degrees Fahrenheit–use the following formulas to write the two methods, and round to the nearest tenth of a degree: – DegreesC = 5(degreesF – 32)/9 – DegreesF = (9(degreesC)/5) + 32; • (2) three mutator methods: one to set the value, one to set the scale (F or C), and one to set both; • (3) three comparison methods: an equals method to test whether two temperatures are equal, one method to test whether one temperature is greater than another, and one method to test whether one temperature is less than another (note that a Celsius temperature can be equal to a Fahrenheit temperature as indicated by the above formulas); 2 TempDriver Class • Write a driver class to test all the methods. Be sure to use each of the constructors, to include at least one true and one false case for each of the comparison methods, and to test at least the following temperature equalities: 1 – 0.0 degrees C = 32.0 degrees F – -40.0 degrees C = -40.0 degrees F – 100.0 degrees C = 212.0 degrees F 3 Submission Run your program make sure it is working correctly. Please submit your source files: Temperature.java and TempDriver.java to blackboard

need code in java …….

Expert Answer

 

code

solution

output

copyable code

//Tempreture.java

class Tempreture

{

private float value1;

private char scale1;

//four constructor

public Tempreture(float value1)

{

this.value1=value1;

this.scale1=’C’;

}

public Tempreture(char scale1)

{

this.value1=0;

this.scale1=scale1;

}

public Tempreture(float value1,char scale1)

{

this.value1=value1;

this.scale1=scale1;

}

public Tempreture()

{

this.value1=0;

this.scale1=’C’;

}

public float getCelsius()

{

if (scale1 == ‘C’)

{

return value1;

}

else

{

return (5*( value1 – 32 )) / 9;

}

}

public float getFahrenhiteval()

{

if (scale1 == ‘C’)

{

return ((9*( value1 / 5 ))/5) + 32;

}

else

{

return value1;

}

}

public void setvalue1(float value1)

{

this.value1=value1;

}

public void setscale1(char scale1)

{

this.scale1=scale1;

}

//value and scale

public void bothvalue(float value1,char scale1)

{

this.value1=value1;

this.scale1=scale1;

}

public boolean equals(Tempreture object)

{

if (scale1 == ‘C’)

{

if (value1 == object.getCelsius())

{

return true;

}

else

{

return false;

}

}

else

{

if (value1 == object.getFahrenhiteval())

{

return true;

}

else

{

return false;

}

}

}

public boolean highvalue(Tempreture object)

{

if (scale1 == ‘C’)

{

if (value1 > object.getCelsius())

{

return true;

}

else

{

return false;

}

}

else

{

if (value1 > object.getFahrenhiteval())

{

return true;

}

else

{

return false;

}

}

}

public boolean lessvalue(Tempreture object)

{

if (scale1 == ‘C’)

{

if (value1 < object.getCelsius())

{

return true;

}

else

{

return false;

}

}

else

{

if (value1 < object.getFahrenhiteval())

{

return true;

}

else

{

return false;

}

}

}

//To string

public String toString()

{

if (scale1 == ‘C’)

{

return “The value of tempreture in celsius is:ttt”+value1+”nThe value of tempreture in Fahrenhite is:tt”+getFahrenhiteval();

}

else

{

return “The value OF temp in c is:ttt”+getCelsius()+”nThe value of tempreture in F is:tt”+value1;

}

}

}

//TempDriver.java

public class TempDriver

{

public static void main(String[] args)

{

//0.0 C

Tempreture ob1 = new Tempreture();

Tempreture ob2 = new Tempreture(32,’F’);

Tempreture ob3 = new Tempreture(-40);

Tempreture ob4 = new Tempreture(-40,’F’);

Tempreture ob5 = new Tempreture(100,’C’);

Tempreture ob6 = new Tempreture(212,’F’);

System.out.println(“object 1n”);

System.out.println(ob1);

System.out.println(“nobject 2n”);

System.out.println(ob2);

System.out.println(“nobject 3n”);

System.out.println(ob3);

System.out.println(“nobject 4n”);

System.out.println(ob4);

System.out.println(“nobject 5n”);

System.out.println(ob5);

System.out.println(“nobject 6n”);

System.out.println(ob6);

System.out.println(“—————n—————“);

System.out.println(“The value of object 3 is low than object 1 value”);

System.out.println(ob3.lessvalue(ob1)+”n”);

System.out.println(“the value of obje 4 is high than obj 5 value”);

System.out.println(ob4.highvalue(ob5)+”n”);

System.out.println(“find C of obj 4″);

System.out.println(ob4.getCelsius()+”nn”);

System.out.println(“find F of obj 3″);

System.out.println(ob3.getCelsius()+”nn”);

System.out.println(“value 15 to obj 1”);

ob1.setvalue1(15);

System.out.println(“result:”);

System.out.println(ob1+”nn”);

System.out.println(“scale C to obj 2”);

ob2.setscale1(‘C’);

System.out.println(“results:”);

System.out.println(ob2+”nn”);

System.out.println(“scale F and the value 34 to obj 5 value”);

ob5.bothvalue(34,’F’);

System.out.println(“results:”);

System.out.println(ob5+”nn”);

 

}

}

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.