Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: PLEASE HELP

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default PLEASE HELP

    My professor assigned this program for us but she explained very poorly and i honstelly don't understand this at all how to do this. I have been staring at it for a week now. I just started programming so i don't understand very much right now.

    Write a Java program that reads data from an input file (provided with this description) called weatherData.txt, performs a set of calculations on the data, and writes results out to one of three output files. The file contains a series of double values representing data about weather over a period of time.

    The data are arranged in rows, with have one or two numbers in each row. The first number represents a temperature in degrees Fahrenheit. The second number, if present, represents either a wind speed or a relative humidity reading. The first value determines the meaning of the second value, and whether or not it is even present, as follows:
    if the temperature is at or above 80 degrees Fahrenheit, the second number represents relative humidity; for example, 75% relative humidity would be recorded in the file as 0.75
    if the temperature is below 50 degrees Fahrenheit, the second number represents wind speed in miles per hour
    if the temperature is between 50 and 80 (exclusive), there is no second number

    Calculating wind chill factor
    Wind chill factor is the effect of wind speed on perceived temperature; the calculated value represents how the air temperature feels on exposed skin with the wind blowing. The formula for calculating WCF is:
    WCF = 35.74 + 0.6215T 35.75(V0.16) + 0.4275T(V0.16)
    where T is the temperature in degrees Fahrenheit and V is the wind speed in miles per hour.

    Calculating heat index
    Heat index is the summer equivalent of WCF; it represents the effect of humidity on air temperature. The formula for calculating HI may be found in the description for program assignment #1.

    Calculating Celsius equivalent
    tempC = (5/9)(temp-32)
    // hint: be careful with data types!

    Your program should:
    Open the files (one for input, three for output; you will need to create the output files, but you should copy the input file to your own computer or flash drive to use for your program)
    Read data from the input file and process each input line as follows:
    If the temperature value is 50 or below, read the corresponding wind speed, calculate WCF and send output to the file cold.txt
    If the temperature value is 80 or above, read the corresponding relative humidity, calculate HI and send output to the file hot.txt
    If neither of the above is true, calculate the Celsius equivalent of the temperature and send the output to the file conversions.txt

    Output format
    Each file should present your data in tabular form, with headings. For example, hot.txt should look something like this:

    Temperature
    Humidity
    Heat Index
    82
    50
    83
    95
    50
    105

    here is the input file weatherData.txt

  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: PLEASE HELP

    You've posted your entire assignment without asking a specific question, and unfortunately that makes it difficult if not impossible for us volunteers in this and other forums to be able to help you. I know that the task seems daunting, but its eminently do-able if you follow certain rules some of which include:
    • read your assignment over several times to make sure you fully understand it.
    • If any specific part confuses you, then post your question here. Don't simply post the entire assignment as there's little specific help we can give, but if you ask about specific points such as "this statement here confuses me -- ' ... '", we'll be much better able to give you specific help.
    • Most important, break the big task down into small tasks.
    • Then start trying to solve each small task in isolation.
    • This way if you get stuck at a specific step, again you can come back here with your code attempts, your errors, and your specific questions. Do this and we can help you correct your code and move you forward.


    Some of the specific steps that it seems to me you must tackle include
    • Reading data in from the data file. I would recommend that you first try to write a small program that does nothing but read in the text in the file and then prints it out to the screen.
    • Once you've solved that, you can work on extracting the information held in the file line by line (called rows in your assignment).
    • Get each line of information one at a time, a while loop and a Scanner will work well for this.
    • Try to extract the information held on each line. Either a Scanner or String#split(...) could work well for this.
    • Convert the number Strings held on the line into actual numbers.
    • Then try to analyze them.
    • ... keep going till solved or you run into a speed bump.
    • And if you run into a speed bump, come on back, show your code and ask your questions.


    Good luck

  3. The Following User Says Thank You to curmudgeon For This Useful Post:

    copeg (October 19th, 2012)