I have a project for class where we have two arrays (high and low) that we are going to store high and low temperatures for each day during a month. We need to have a number that is out of the ordinary so if the person entering information into the arrays forgot to take a temp for a day it would be that default number (510 is what I chose). So what I currently have is a program that prints out the day but all the temperatures are 510. Can someone explain to me what I need to do to the while loop to get the info entered to go into the correct high and low arrays? Also is there a way to enter nothing (if the person recording temperatures forgot to take a temperature for the high) and have it remain 510 degrees?
import java.util.Scanner;
import javax.swing.JOptionPane;
public class Weather {
public static void main(String[] args) {
// TODO Auto-generated method stub
int [] high = new int[30];
int [] low = new int[30];
//switch to 32
Init (high);
Init(low);
Report(low,high);
LoadData(low,high);
Report(low, high);
}
public static void Init(int A[])
{
for(int i = 0; i < A.length; i++)
{
A[i] = 510;
}
}
public static void Report(int[] H, int[] L)
{
System.out.println("Day High Low");
for(int i = 0; i < H.length; i++)
{
System.out.println(i + " " + H[i] + " " + L[i]);
}
}
public static void LoadData(int[] H, int[] L)
{
int day = 0;
while(day <= 30)
{
int high = Integer.parseInt(JOptionPane.showInputDialog("please enter the high"));
int low = Integer.parseInt(JOptionPane.showInputDialog(" Please enter the low"));
H[day] = high;
H[day] = low;
day++;
}
}
}