Hi!
I want to create a loop
which takes the top number from each array
and plugs it in to a formula
all the way through the arraylist.
One array has 12 temperatures in F, such as 89.1 and so forth
The other array has 12 relative humidities.
I've gotten it down to the loop and the formula, but it doesn't work. I think I am missing something simple.
The formula is for the so-called Heat Index.
/** * Write a description of class HeatIndex here. * * @author (your name) * @version (a version number or a date) */ import java.util.ArrayList; import java.io.File; import java.io.IOException; import java.util.Scanner; public class HeatIndex{ public static void main(String [] args) throws IOException { // int index = 0; double [] KeyWestTemp = new double[12]; int [] KeyWestHumid = new int[12]; File KeyWestTempFile = new File("KeyWestTemp.txt"); File KeyWestHumidFile = new File("KeyWestHumid.txt"); Scanner inFile1 = new Scanner(KeyWestTempFile); Scanner inFile2 = new Scanner(KeyWestHumidFile); // Print to file Thing ArrayList<Double> Temp = new ArrayList<>(); while (inFile1.hasNext()) { Temp.add(inFile1.nextDouble()); } System.out.println(Temp); ArrayList<Integer> Hume = new ArrayList<>(); while (inFile2.hasNext()) { Hume.add(inFile2.nextInt()); } System.out.println(Hume); for(String number: Hume) //? { number * heatIndex; // have to figure out the correct way to multiply things within a loop. } // In the formula below,the values should be drawn, one by one, from the two arrays. and it should give twelve //results, because there are twelve humidity values and twelve temperature values. Any help would be great. for double heatIndex = -42.379 + 2.0490153*"Temp" + 10.14333127*"Hume" - 0.22475541*"Temp"*"Hume"-6.8783*10^3*"Temp"^2 - 5.481717*10^-2*"Hume"^2 + 8.5282*10^-4*"Temp"*"Hume"^2 - 1.99*10^-6*"Temp"^2*"Hume"^2 Temp // for(int Gooba : KeyWestTemp) //{ // System.out.println(Gooba); //} // inFile1.close(); } }