Question

COMP163 Greensboro Weather Trends There has been significant debate about global warming. Instead of answering the big question, your program is to determine if (and by how much) Greensboro has been warming for the past few decades. For this assignment you are to write a program that reads a file created with data from the National Climatic Data Center to determine the average annual minimum temperature. This value for all years is then statistically averaged to determine by how much the value is increasing. The file weatherDaily.dat contains several years of Greensboro daily weather data sorted by increasing date Each line in the file represents one days weather and contains the values year month date of this weather record date of this weather record from 1 to 12 date of this weather record from 1 to 31 precipitation amount of precipitation on this day in tenths of a centimeter snow daily high highest temperature recorded on this dav in tenths of a degree Celsius daily lowlowest temperature recorded on this day in tenths of a degree Celsius amount of snow that fell on this day in tenths of a centimeter All values are integers. The program only requires the year, month, day and daily low, although your program must read all data values in each line. Each year in the file starts with January 1 and ends with December 31. The temperature in tenths of a degree Celsius can be converted to degrees Fahrenheit by 9.C + 32.0 To calculate the average annual low temperature for a year, the program must sum 50 the low temperature for each day and count the number of days. On December 31, the program should divide the sum of the daily lows by the number of days to get the average low temperature. While the average changes each year, a long term trend can be found by calculating a least squares fit to the annual average low data. The slope of an average line though the data can be calculated by numYears * X(year * avg) - 2 year * L avg numYears * Lyear2 - Lyear* Lyear where: numYears is the number of years of is the sum of the years (i.e. 1974 + 1975 + 1976+ +2015) ear yearis the sum of the square of the years (i.e. 19742+ 19752 +1976 is the sum of the annual average low temperature + 20152) avg (year avg) is the sum of each annual average low temperature multiplied by the year numberneed help finiding slope and placement for the farenheit in the eaquation for a java.util.Scanner

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//GreensboroWarning.java
public class GreensboroWarning{
public static void main (String [] args)throws java.io.FileNotFoundException{

  
java.io.File holder= new java.io.File("weatherDaily.txt");
java.util.Scanner read= new java.util.Scanner(holder);

int year, month, day, precipitation, snow, dailyHigh, dailyLow;
int counterDay=0;
int counterYear=0;// initallize variable to 0
int sumOfYear=0;// initalliaze variable to 0
int yearSquared=0;
double sumAverageLow=0;
double sumYearTAverLow=0;
double fahHigh;
double fahLow=0.0;
double averageLow=0,slope=0;
double slopedegree;
while (read.hasNext()){
year=read.nextInt();// read first integer for year
month=read.nextInt();// read second integer for month
day=read.nextInt();// read third integer for day
precipitation=read.nextInt();
snow=read.nextInt();// fifth for snow
dailyHigh=read.nextInt();//sixth for daily high temp

dailyLow=read.nextInt();// seventh for daily low temp
fahLow+=((9.0* dailyLow)/50.0)+32.0;// change degree to fah

counterDay++;//count the days
if (month==12 && day==31){
averageLow= fahLow/(counterDay*1.0);
System.out.println(year+ " " +averageLow);
counterYear++;
sumOfYear+=year;
yearSquared+=year * year;
sumAverageLow+=averageLow;
sumYearTAverLow+=year*averageLow;  
counterDay=0;
fahLow=0;


}
}
  
slope=(counterYear*sumYearTAverLow-sumOfYear*sumAverageLow)/(counterYear* yearSquared -sumOfYear*sumOfYear);// calculate temp
System.out.println("increase in annual low is "+slope+ " degrees per year");// display the temperture
slopedegree=(1/slope);
System.out.println(+slopedegree+"years to change one degree");

  
}

}

=========================================================================

sample output

Error Log Tasks L Problems Console X Search | <terminated> GreensboroWarning [Java Application C:Program Files Javajre7 bin j

Add a comment
Know the answer?
Add Answer to:
need help finiding slope and placement for the farenheit in the eaquation for a java.util.Scanner COMP163...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Write a C++ program that reads daily weather observation data from a file and writes...

    1. Write a C++ program that reads daily weather observation data from a file and writes monthly and annual summaries of the daily data to a file. a. The daily weather data will be contained in a file named wx_data.txt, with each line of the file representing the weather data for a single day. b. For each day, the date, precipitation amount, maximum temperature, and minimum temperature will be provided as tab-separated data with the following format: 20180101 0.02 37...

  • Assume that, for a given town, mid-day daily temperature in Fahrenheit was measured for a month...

    Assume that, for a given town, mid-day daily temperature in Fahrenheit was measured for a month and stored in a file called temperature.txt. Write a complete C Language program that reads the stored temperatures, one at a time, from the file temperature.txt and converts the read temperature to its equivalent in Celsius. Your program should store each converted temperature in an output file called results.txt. Your program should find the average, the minimum, and the maximum temperatures in Celsius and...

  • Assume that, for a given town, mid-day daily temperature in Fahrenheit was measured for a month...

    Assume that, for a given town, mid-day daily temperature in Fahrenheit was measured for a month and stored in a file called temperature.txt. Write a complete C language program that reads the stored temperatures, one at a time, from the file temperature.txt and converts the read temperature to its equivalent in Celsius. Your program should store each converted temperature in an output file called results.txt. Your program should also find the average, the minimum, and the maximum temperatures in Celsius...

  • Hello, I am having some difficulty with interpreting the data below to fill in the table...

    Hello, I am having some difficulty with interpreting the data below to fill in the table required (which is displayed below the data charts). Any help or advice would be greatly appreciated. Question: Fill in the following table based upon the data charts given Question 2005 2006 2007 2008 For each year, at what date did the water temperature first hit 1°C above expected summertime maximum? For each year, at what date did the water temperature first hit 2°C above...

  • On this project you will make calculations and conclusions based on real data collected by the...

    On this project you will make calculations and conclusions based on real data collected by the NOAA (The National Oceanic and Atmospheric Administration, an agency of the United States government) on the “Daily Lake Average Surface Water Temperature” of six lakes (Ontario, Erie, Huron, Michigan, Superior, and St. Clair) during the 2019 calendar year. You can find the actual data file here that contain the average temperatures for each day of the year for each of the six lakes. Data...

  • Hello! I have this python Homework due tonight that I don't know how to do. Here...

    Hello! I have this python Homework due tonight that I don't know how to do. Here is a document with the data in the csv file, as I didn't know how to share it https://docs.google.com/document/d/1bDJVR2MqWKInvw5u0r3fOG3-CBmu3BEiPZwlaq_CShQ/edit?usp=sharing Activity #3: On the class website is a CSV file containing weather data from Coulter Field (in Bryan) for 3 years (1 day is missing for some reason!); the data was taken from Weather Underground (wunderground.com). There are different versions of the file for Windows...

  • I need help using python ( spyder) only use files , loops if needed is statement do not use , def...

    i need help using python ( spyder) only use files , loops if needed is statement do not use , def function or any other. Exercise 1: Daily temperature is recorded for some weeks in files (templ.txt", temp2.txt, and temp3.txt; provided in the MOODLE). The first line contains number of weeks and the rest of the lines each represent the week number followed by temperature on the seven days of that week (see samples input files below). Write a python...

  • Please Read it all and carefully In visual basic(vba)do the following program Summary INGE Industry, Inc....

    Please Read it all and carefully In visual basic(vba)do the following program Summary INGE Industry, Inc. needs a program in which the date and temperature in Celsius degrees of an industry laboratory are recorded and stored in a sequential file. In addition, you can see the recorded data and convert the temperatures in the following units: Fahrenheit, Kelvin and Rankine. In addition, they want to see a linear graph that reflects how the temperature has fluctuated day by day, for...

  • C++: Need help debugging my code I am writing this and using some other examples as reference code while rewriting it with my own understanding of the material but am having trouble making it finally...

    C++: Need help debugging my code I am writing this and using some other examples as reference code while rewriting it with my own understanding of the material but am having trouble making it finally compile. Below is a picture of the error messages. //main.cpp //Semester Project //Created by J---on 5/6/2019 #include <iostream> #include <fstream> #include <string> #include <sstream> #include <bits/stdc++.h> using namespace std; void instructions(); //displays program details and instructions void openFile(); void takeInput(int*); void switchBoard(int*); struct price {...

  • The following is a program from Starting out with C++ by Toni Gaddis. I am getting the following error messages pertain...

    The following is a program from Starting out with C++ by Toni Gaddis. I am getting the following error messages pertaining to the lines: cin>>month[i].lowTemp; and months[i].avgTemp = (months[i].highTemp + month[i].lowTemp)/2; The error messages read as follows: error C2039: 'lowTemp': is not a member of 'std::basic_string<_Elem,_Traits,_Ax>' and it continues. The second error message is identical. The program is as follows: Ch. 11, Assignment #3. pg. 646. Program #4. //Weather Statistics. //Write a program that uses a structure to store the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT