hello, i'm try to write a program to convert an array of Fahrenheit temperatures to Celsius. I have the fahrenheit temps but i don't know how to convert them to celsius. I have to create a method to convert them. Any suggestions??
here is my code that I have so far...
import java.util.*;
public class Program1
{
public static void main(String[] args)
{
// Obtain user input for the Location
Scanner input = new Scanner(System.in);
String location = input.nextLine();
System.out.println("Temperatures in " + location);
// Create an array for the temperatures
System.out.println("Enter Temperatures in Fahrenheit");
double temp1 = input.nextDouble();
double temp2 = input.nextDouble();
double temp3 = input.nextDouble();
double temp4 = input.nextDouble();
double temp5 = input.nextDouble();
double temp6 = input.nextDouble();
double temp7 = input.nextDouble();
double temp8 = input.nextDouble();
double temp9 = input.nextDouble();
double temp10 = input.nextDouble();
double [] tempsList;
tempsList = new double [] {temp1,temp2,temp3,temp4,temp5,temp6,temp7,temp8,temp9,temp10};
System.out.printf("%s\n", " Fahrenheit");
{
// Print the user defined fahrenheit temperatures
for (int i = 0; i < tempsList.length; i++)
System.out.printf("%10.1f\n", tempsList[i]);
}
//Method to print the user defined celsius temperatures
double celsius = convertToCelsius(tempsList);
System.out.print("Celsius " + celsius);
}
/**
* Calculates highest temperature
* @param celsius
* @param array and largest
* @return
*/
public static double convertToCelsius(double[] tempsList)
{
double[] result;
result = new double [10];
for (int i = 0; i < tempsList.length; i++)
{
result = tempsList
}
}
}
here is my code that I have so far...
import java.util.*;
public class Program1
{
public static void main(String[] args)
{
// Obtain user input for the Location
Scanner input = new Scanner(System.in);
String location = input.nextLine();
System.out.println("Temperatures in " + location);
// Create an array for the temperatures
System.out.println("Enter Temperatures in Fahrenheit");
double temp1 = input.nextDouble();
double temp2 = input.nextDouble();
double temp3 = input.nextDouble();
double temp4 = input.nextDouble();
double temp5 = input.nextDouble();
double temp6 = input.nextDouble();
double temp7 = input.nextDouble();
double temp8 = input.nextDouble();
double temp9 = input.nextDouble();
double temp10 = input.nextDouble();
double [] tempsList;
tempsList = new double [] {temp1,temp2,temp3,temp4,temp5,temp6,temp7,temp8,temp9,temp10};
System.out.printf("%s\n", " Fahrenheit");
{
// Print the user defined fahrenheit temperatures
for (int i = 0; i < tempsList.length; i++)
System.out.printf("%10.1f\n", tempsList[i]);
}
//Method to print the user defined celsius temperatures
double celsius = convertToCelsius(tempsList);
System.out.print("Celsius " + celsius);
}
/**
* Calculates highest temperature
* @param celsius
* @param array and largest
* @return
*/
public static double convertToCelsius(double[] tempsList)
{
double[] result;
result = new double [10];
for (int i = 0; i < tempsList.length; i++)
{
result = tempsList
}
}
}