Question: Instructions 1. Create a NetBeans Java application project and name it PA5_yourid. 2. Create a second Java class file and name it Celsius. In the

Instructions 1. Create a NetBeans Java application project and name it "PA5_yourid".

2. Create a second Java class file and name it "Celsius". In the Celsius class, (a) create a private data member to hold one temperature in degrees Celsius. Initialize it to absolute zero (273.15)

(b) create a default constructor

(c) create a preferred constructor that receives a single temperature value and assigns that value to the private data member iff the value is greater than absolute zero

(d) create a copy constructor that receives a Celsius object reference and uses the temperature stored in that object to initialize the temperatures variable of this object.

(e) create a getter method that receives nothing and returns the value of the temperature data member. (f)

create a setter method that receives a a single temperature value and assigns that value to the private data member iff the value is greater than absolute zero. (g)

create a standard toString method that returns a string containing the temperature stored in the private data member concatenated to the phrase " Celsisus".

CMPS 260 Fall 2017 Programming Assignment #5 (20171012) 2 3. In the class PA5_yourid, (a) create a public static void method that receives an array of type Celsius and outputs each temperature stored in private data member of each Celsius object referenced by the elements of the received array. Output should be in the form of Temperature # is ## degrees Celsius where # is the index of the element referencing the Celsius object and ## is the temperature store in that object.

(b) in the method main, i. create an array of type Celsius that can store references to 5 objects of type Celsius. ii. traverse the array, creating a Celsius object from a temperature received from the user for each element in the array, placing the reference to each Celsius object in an element of the array. I. e. store the 5 temperatures the user enters in Celsius objects and assign these object to the 5 array elements. iii. call the method created in (a) to display the temperatures stored in the elements in the array.

iv. Create a Celsius object using the copy constructor of class Celsius, passing in the object referenced at index 2 of the array. Then A. use a call to method toString to output the value stored in the new object.

B. change the value stored in the new object by a call to the setter method.

C. use a call to method toString to output the value stored in the new object to show the change (if any).

Example run: Enter temperature in degrees Celsius: 40 Enter temperature in degrees Celsius: 22 Enter temperature in degrees Celsius: 0 Enter temperature in degrees Celsius: -40 Enter temperature in degrees Celsius: -500 Temperature 0 is 40.0 degrees Celsius Temperature 1 is 22.0 degrees Celsius Temperature 2 is 0.0 degrees Celsius Temperature 3 is -40.0 degrees Celsius Temperature 4 is -273.15 degrees Celsius 0.0 Celsius 100.0 Celsius

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!