Hi how do accomplish these I am stuck at here PLEASE edit from my code here. I w
ID: 3913549 • Letter: H
Question
Hi how do accomplish these I am stuck at here PLEASE edit from my code here. I want to learn thank you
import java.util.Scanner;
public class temp { /* This program will calculate the average of three numbers */
public static void main(String[] args) { int i; //float arr[] = {11, 22, 33, 44, 55}; // CHECKER float[] arr = new float[10];
Scanner sc = new Scanner(System.in); for (i=0; i<5; i++) { arr[i] = sc.nextFloat(); System.out.println(arr[i]); minFunction(arr[i]); } sc.close();
} // end main() public static float minFunction(float input) { int i; float celsius,avg=0;
celsius=(((input*9)/5)+32); System.out.println("fareeieiti "+celsius) return avg; }
} // end class import java.util.Scanner;
public class temp { /* This program will calculate the average of three numbers */
public static void main(String[] args) { int i; //float arr[] = {11, 22, 33, 44, 55}; // CHECKER float[] arr = new float[10];
Scanner sc = new Scanner(System.in); for (i=0; i<5; i++) { arr[i] = sc.nextFloat(); System.out.println(arr[i]); minFunction(arr[i]); } sc.close();
} // end main() public static float minFunction(float input) { int i; float celsius,avg=0;
celsius=(((input*9)/5)+32); System.out.println("fareeieiti "+celsius) return avg; }
} // end class 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 ((Cx 9)/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_temp0) 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 main0. Display this average value in the main0. 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_Kelvin) 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 main0. Display this average temperature in Kelvin.
Explanation / Answer
temp.java
import java.util.Arrays;
import java.util.Scanner;
public class temp {
/* This program will calculate the average of three numbers */
public static void main(String[] args) {
int i;
//float arr[] = {11, 22, 33, 44, 55}; // CHECKER
float[] arr = new float[5];
Scanner sc = new Scanner(System.in);
System.out.println("Enter "+arr.length+" temparatures: ");
for (i=0; i<5; i++)
{
arr[i] = sc.nextFloat();
}
float avgCelcius = convert_temp(arr);
System.out.println("Farenhheit array: "+Arrays.toString(arr));
System.out.println("Kelvin Temp: "+in_Kelvin(avgCelcius));
sc.close();
} // end main()
public static float convert_temp(float []arr) {
float avg = 0;
float total = 0;
for(int i=0;i<arr.length;i++) {
total += arr[i];
arr[i] = (arr[i] * 9) / 5 + 32;
}
avg = total/arr.length;
return avg;
}
public static float in_Kelvin(float avgCelcius) {
return avgCelcius+273;
}
} // end class
Output:
Enter 5 temparatures:
1.1
2.2
3.3
4.4
5.5
Farenhheit array: [33.98, 35.96, 37.94, 39.920002, 41.9]
Kelvin Temp: 276.3
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.