I'm using Eclipse for this program and I'm trying to do is get the program to read the text file "ClimateDataA" and then find the date of the first time the temperature is under 80 degrees and I have to use for & while loops.
This is what the text file "ClimateDataA" contains:
14939 20140801 86
14939 20140802 90
14939 20140803 93
14939 20140804 87
14939 20140805 93
14939 20140806 83
14939 20140807 81
14939 20140808 83
14939 20140809 85
14939 20140810 85
14939 20140811 80
14939 20140812 81
14939 20140813 87
14939 20140814 89
14939 20140815 76
14939 20140816 87
14939 20140817 92
14939 20140818 91
14939 20140819 93
14939 20140820 96
14939 20140821 90
14939 20140822 93
14939 20140823 95
14939 20140824 91
14939 20140825 83
14939 20140826 81
14939 20140827 77
14939 20140828 82
14939 20140829 75
14939 20140830 87
14939 20140831 92
Column 1 is an ID number. Column 2 is the date. Column 3 is the temperature.
This is my code so far:
import java.util.Scanner;
import java.io.*;
public class ClimateSummary
{
public static void main (String [] args) throws FileNotFoundException
{
Scanner userInfo = new Scanner (new File("MyInfo.txt"));
Scanner weatherData = new Scanner (new File("ClimateDataA.txt"));
String userName = userInfo.nextLine();
String userBirthPlace = userInfo.nextLine();
int userBirthDay = userInfo.nextInt();
String userBirthMonth = userInfo.next();
int userBirthYear = userInfo.nextInt();
String dataLocation = userInfo.next();
int [][] myArray = new int[31][3];
for (int i = 0; i < myArray.length; i++) {
}
System.out.println("Welcome " + userName + "! This is the Super Computing Weathernator 3000!");
System.out.println();
System.out.println("Name: " + userName);
System.out.println("Date of birth: " + userBirthDay + " " + userBirthMonth + " " + userBirthYear );
System.out.println("Place of birth: " + userBirthPlace);
System.out.println("Data collected at: " + dataLocation);
System.out.println();
System.out.println("The first day under 80 degrees is ");
userInfo.close();
}
}
Without these lines of code the program can run.
Scanner weatherData = new Scanner (new File("ClimateDataA.txt"));
int [][] myArray = new int[31][3];
for (int i = 0; i < myArray.length; i++) {
}
This is the output I'm trying to get:
Welcome Eric Hornberger! This is the Super Computing Weathernator 3000!
Name: Eric Hornberger
Date of birth: 18 February 1960
Place of birth: Columbus, Nebraska
Data collected at: Columbus
The first day under 80 degrees is 15/08/2014
The first five lines are using data from the "MyInfo" text file.
I'm going to have to parse to get the date exactly like that in the output but I only need help with getting the data I'm looking for.
Can anyone help me do this properly? Thanks for your time!