HeyI was wondering if anyone can help me with this? Im basically attempting to write a program that reads data for the temp and rainfall for a week, stores the data in an array and then outputs the data in several different forms. I have it done (or so I thought) but for some bizarre reason its just not working. The program runs fine, takes the info, but all the data fields output as "0". Could use a fresh pair of eyes in a big way :) Any help gladly appreciated
import java.util.Scanner;
public class rainFallProject {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//Creates scanner object
Scanner myScanner=new Scanner(System.in);
//declare array for temperature
int [] tempList = new int[7];
//declare array for rainfall
int [] rainList = new int[7];
//NOTE all arrays need only be 7 places long, as there will only ever be 7 entries
//declare a variable for the just entered temp
int tempInput;
//declare a variable for the just entered rainfall
int rainInput;
//declare variable for highest temp
int highestTemp=0;
//declare variable for lowest rainfall amount
int lowestRain=0;
for(int i = 0; i < tempList.length; i++){
//Prompt the user to enter a temperature
System.out.format("Please enter the temperature for day %d:", i+1);
//stores the input as just entered temp
tempInput = myScanner.nextInt();
//Assigns the temp to its correct place in the array
tempInput = tempList[i];
//updates the highest temp, if necessary
if(tempInput>highestTemp){
tempInput=highestTemp;
}
//Prompt the user to enter the rainfall amount
System.out.format("Please enter the rainfall for day %d:", i+1);
//stores the input as just entered rainfall
rainInput = myScanner.nextInt();
//Assigns the rain to its correct place in the array
rainInput = rainList[i];
//updates the lowest rain, if necessary
if(rainInput<lowestRain){
rainInput=lowestRain;
}
}
//Declare the total temperature
int tempSum = (tempList[0]+tempList[1]+tempList[2]+tempList[3]+tempList[4]+tempList[5]+tempList[6]);
//Declares the total rainfall
int rainSum = (rainList[0]+rainList[1]+rainList[2]+rainList[3]+rainList[4]+rainList[5]+rainList[6]);
//Output the results:
//-Weekly average temperature ((sum of all temps)/7)
System.out.format("The weekly average temperature was %d degrees celsius. %n", (tempSum/7));
//-Highest temperature of the week
System.out.format("The highest temperature for the week was %d degrees celsius.%n", highestTemp);
//-Total weekly rainfall amount (sum of all rainfalls)
System.out.format("The total weekly rainfall amount for the week was %d mm. %n", rainSum);
//-Lowest daily rainfall amount
System.out.format("The lowest amount of rainfall for the week was %d mm. %n", lowestRain);
}
}