Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi how to do this Assessment 2 Write a Java program to do the following: 1. In y

ID: 3913068 • Letter: H

Question

Hi how to do this
Assessment 2 Write a Java program to do the following: 1. In your main0, enter a set of 5 temperatures (representing Celsius) into an array of float 2. Write a method called convert_temp0 that accepts 1 parameter (a float array) and returns a numbers. float number. This method is used to convert an array of Celsius temperatures (passed as a parameter) into their equivalent Fahrenheit temperatures using the formula: F ((Cx9)/5)+32 Note: The method must return the average of the Celsius temperatures 3. In the main), call the method convert_temp) and pass the array containing your Celsius 4. In the convert temp() method, display each temperature in Celsius and the corresponding 5. In the convert temp) method, calculate the average Celsius temperature from the array of 5 temperatures you entered (step 1) as a parameter. value in Fahrenheit beside it. temperatures passed as a parameter and return this average to the main). Display this average value in the main). 6. Write another method called in_Kelvin0 that accepts 1 parameter (a float number) and returns a float number. When this method is called, the parameter passed to this method is a single float Celsius temperature number. The method then calculates the equivalent temperature in Kelvin using the formula: "?"; °C + 273 7. In the main), call the function in_Kelvin0 and pass the average Celsius temperature (step 5) to this method where it will calculate the equivalent temperature in Kelvin. The method must return the calculated Kelvin temperature back to the main). Display this average temperature in Kelvin.

Explanation / Answer

import java.util.*;

class Fun

{

float convert_temp(float a[])//convert_temp function

{

int i=0;

float avg=0;

for (i=0;i<5;i++)//calculating corresponding farenheat value for every celcius value

{

System.out.print("celsius vaule="+a[i]);

avg=avg+a[i];

a[i]=((a[i]*9)/5)+32;

System.out.println(" and farenheat value="+a[i]);

}

avg=avg/5;//finding average

return avg;//returning average of celsius values

}

float in_kelvin(float cel)

{

return cel+273;//calculating and returning kelvin temperature

}

}

class Temp

{

public static void main(String arg[])

{

float a[]=new float[5];//float array five temperatures

int i=0;float avg_cel;

System.out.println("enter 5 temperatures in celcius");

Scanner s=new Scanner(System.in);

for (i=0;i<5;i++) //taking celcius temperatures as input

a[i]=s.nextInt();

Fun f=new Fun();

avg_cel=f.convert_temp(a);//calling conver_temp

System.out.println("average celcius value="+avg_cel);//printing average celcius value

System.out.println("temperature in kelvin"+ f.in_kelvin(avg_cel));//calling in_kelvin() function

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote