Hi all,
I need some help with the code below. The general idea of the code is to propmt the user for different int values and output these values in a formatted way, this invloves
alot of loops and for loops. All looks well apart from the message: "expection in
thread "main" "....
here is the code:
import java.io.*;
import java.text.*;
public class prac10weather1
{
static BufferedReader myInput = new BufferedReader(new InputStreamReader( System.in));
// defining new arrays that will hold 7 values for 7 days of the week
static int max_temp [] = new int [7];
static int min_temp [] = new int [7];
static int humidity [] = new int [7];
static int i; // it is very important that these two variables are declared as 'static'
static int n; // doing this ensures that they are available throughout the entire program
// static program variables that are available throughout the program
static int maxTemp;
static int minTemp;
static int hum;
static int NumberOfDays;
static int NumberOfStars;
static
String input_string_number_of_days;
static String input_String_max_temp;
static String input_String_min_temp;
static String input_String_hum;
public static void readInput() throws IOException
{
// Here the user is prompted for the number of days
// The number is then put into a new variable called NumerOfDays
System.out.print("How many days weather do you wish to enter?: ");
input_string_number_of_days = myInput.readLine();
int NumberoOfDays = Integer.parseInt(input_string_number_of_days);
for(int n=0; n<NumberOfDays; n++)
{
System.out.println("Enter the Max temperature for Day "+n);
input_String_max_temp = myInput.readLine ();
maxTemp = Integer.parseInt(input_String_max_temp);
System.out.println("Enter the Min temperature for Day "+n);
input_String_min_temp = myInput.readLine ();
minTemp = Integer.parseInt(input_String_min_temp);
System.out.println("Enter the Humidity for Day "+n);
input_String_hum = myInput.readLine ();
hum = Integer.parseInt(input_String_hum);
// after we read the values into the above variables we need to populate the arrays
// the 3 lines of code below populates the max, min & hum arrays with
// the appropriate variable values
humidity[n] = maxTemp;
min_temp[n] = minTemp;
max_temp[n] = hum;
}
}
public static void printResult()
{
System.out.println("-------------------");
System.out.println("Day / Maximum Temp");
System.out.println("-------------------");
for (n=0; n<NumberOfDays; n++)
{
System.out.print(n+min_temp[n]+" ");
NumberOfStars = min_temp[n]/4;
for (i=0; i<NumberOfStars; i++)
{
System.out.print("*");
}
}
}
}
Thank you!!!