
So as you can see, I'm still getting no numbers at the end for the Temperatures. The average of the array of temperatures is 0.0 K Temperature tempAve = new Temperature(sum.temperature/array.length, 'K') Return this.temperature=n.temperature&this.scale=n.scale Return new Temperature(temp1.temperature*temp2.temperature, 'K') ĭouble new_temp=(double)(temp1.temperature/d) Public Temperature multiply(Temperature n) Public Temperature subtract(Temperature n) Return new Temperature(temp1.temperature+temp2.temperature, 'K') Temperature temp = new Temperature(converted_Temp, 'F') Ĭonverted_Temp=(double)(temperature*9.0/5.0 +32) Temperature temp = new Temperature(converted_Temp, 'C') Ĭonverted_Temp=(double)((temperature-32)*5.0/9.0) Temperature temp = new Temperature(converted_Temp, 'K') Ĭonverted_Temp=(double)((temperature-32)*5.0/9.0+273.15) Public Temperature(double temperature, char scale) Any help would be greatly appreciated! Temperature tempArray = new Temperature įor (int i = 0 i < tempArray.length i++) This is what I have so far and I'm not sure where to go from here. I pretty much have the whole assignment complete, but I am having trouble with this last part. I'm having problems with this part: readTemperatures(tempArray) // must write this method Public static Temperature getAverage(Temperature array) Public static void readTemperatures(Temperature array) ("the average of the array of temperatures is " + tempAve ) TempAve = getAverage(tempArray) // must write this method ReadTemperatures(tempArray) // must write this method ("the average temperature is " + tempAve ) Temperature tempAve = new Temperature(0.0, 'C') Temperature temp4 = new Temperature(232.0, 'K') Temperature temp3 = new Temperature(50.0, 'C') Temperature temp2 = new Temperature(100, 'F') Temperature temp1 = new Temperature(120.0, 'C')

Methods add, subtract, multiply and divide all return a Temperature. The class has read(), add(Temperature), subtract(Temperature), Multiply(Temperature), divide(double), equals(Temperature), toKelvin(), toFarhrenheit(), toCelsius(), and toString() methods. a temperature class.In addition to converting between Celsius and Fahrenheit also include Kelvin. Method to read the value of temperature given by the user Method to convert Kelvin to Fahrenheit

Method to convert Fahrenheit to Kelvin Method to convert Fahrenheit to Celcius Method to convert Celcius to Fahrenheit Static Scanner sc = new Scanner(System.in) // Scanner Class The loop will continue to accept choices and perform conversions until the user enters 7. To achieve this, we will use a switch statement in the do-while loop. If the user enters a number between 1-6, the program will perform that particular conversion. The program will provide options from 1-7 and ask the user to enter a choice. The input method will return the value entered by the user to main method. One to scan the input from the user and the other to print the converted value.

From each method, we will return the converted value to the main method. In our program for the temperature converter, we will create six methods, each handling the conversions mentioned above.
