Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java Homework

Name: Anonymous 2011-11-08 22:24

Hey guys, I know this is homework and if you don't feel like helping that's fine. I'm just getting stumped by this code and I'm getting a little desperate.


import java.util.*;
import java.text.DecimalFormat;

public class WeatherStation {    

    static int HowMany = 0;
    static Scanner input = new Scanner(System.in);
    private static double[] Weather, Celsius = new double[HowMany];
    private static double WeatherFSum = 0, WeatherCSum = 0;
    private static double FMean = WeatherFSum / HowMany;
    private static double CMean = WeatherCSum / HowMany;
    public static String Command = "";
   
    private static class WeatherData {
        public String StationDesignation;
        public double Temperature;
       
        public WeatherData(String ID, double Temp) {
            StationDesignation = ID;
            Temperature = Temp;
        }
        };
       
        public static void main(String[] args) {
                System.out.print("What is your command? ");
                Command = input.nextLine();
                if(Command.equals("Fill"))
                    Fill();
                else if(Command.equals("Display"))
                    Display();
            }
       
        public static void Fill() {
            int X;
            String Item;
            double Entry;
            System.out.print("Hello!\n\nHow many weather stations will we be checking on? ");
            HowMany = input.nextInt();
            WeatherData[] Weather = new WeatherData[HowMany];
            for(X = 0; X < HowMany ; X++) {
               
            System.out.println("Please enter the name for WeatherStation" + X + ": ");
            Item = input.next();
            if(Item.equals("Stop")) break;
            System.out.println("Please enter temp in fahreinheit: " );
            Entry = input.nextDouble();
            WeatherData[X] Weather = new WeatherData(Item, Entry);
            }
        }




I know that the last line with WeatherData[X] and all that other stuff is complete crap. I get errors upon errors with that. But I'm trying to work out how to make an array of this datatype that I created, and then assign values from the keyboard to instances of that datatype.

Can anyone help? I've googled and searched around but none of the explanations seem to click.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List