Difference between revisions of "CSC212 Homework 3 2014"

From dftwiki3
Jump to: navigation, search
(Problem #1)
(Problem #1)
Line 8: Line 8:
 
=Problem #1=
 
=Problem #1=
  
* Create a text file in your directory with the [[Temperature Data for Cardiff Bute Park| following text]].  Call it '''temperatures.dat":
+
* Create a text file in your directory with the following lines.  Call it '''temperatures.dat":
 
<br />
 
<br />
 
<code><pre>
 
<code><pre>
Line 35: Line 35:
 
* the total rainfall (rain)
 
* the total rainfall (rain)
 
* the sunshine duration (sun)
 
* the sunshine duration (sun)
 +
<br />
 +
==Your Assignment==
 +
<br />
 +
* Write a program called '''Hw3_1.java''' that will
 +
:# read this file,
 +
:# record the year when the rain was maximum,
 +
:# record the year when the sun was maximum,
 +
:# output this information on two lines of text:
 +
<br />
 +
===Example===
 +
<br >
 +
'''javac Hw3_1.java '''
 +
'''java Hw3_1 temperatures0.dat '''
 +
rain 1977 147.90
 +
sun  1978 188.10
 
<br />
 
<br />
  
 
+
[[CSC212 Lab 5 2014|Lab #5]]
  
  
  
 
Full length [[Temperature Data for Cardiff Bute Park| following text]]
 
Full length [[Temperature Data for Cardiff Bute Park| following text]]

Revision as of 15:44, 24 September 2014

--D. Thiebaut (talk) 16:21, 24 September 2014 (EDT)


This homework is due on Oct. 2nd, 2014, at 11:55 p.m.


Problem #1

  • Create a text file in your directory with the following lines. Call it temperatures.dat":


   1977   9   18.3     8.1       0    48.6   117.9
   1977  10   15.4     9.0       0    76.0    80.4
   1977  11   10.3     4.7       4   147.9    76.4
   1977  12    9.6     4.6       2    88.0    25.6
   1978   1    7.5     2.0       6   134.1    64.7
   1978   2    6.2     0.9      13   134.1    56.9
   1978   3   10.6     3.9       3   121.3   122.4
   1978   4   10.9     3.7       4    63.6   118.6
   1978   5   17.3     7.5       0    30.6   188.1
   1978   6   18.5     9.5       0    29.6   177.3
   1978   7   18.7    11.8       0   110.1   115.8
   1978   8   19.6    11.4       0    40.5   164.9
   1978   9   18.4    10.2       0    34.1   182.2
   1978  10   16.6     9.0       0    12.0    81.1


These numbers are weather numbers for Cardiff Bute Park, in the U.K. The 7 numbers on each line represent the following quantities, shown here with their standard abbreviation:

  • the year of the recording (yyyy)
  • the month of the recording (mm)
  • the max daily temperature in degrees Celcius (tmax)
  • the min daily temperature in degrees Celcius (tmin)
  • the number of days of frost (af)
  • the total rainfall (rain)
  • the sunshine duration (sun)


Your Assignment


  • Write a program called Hw3_1.java that will
  1. read this file,
  2. record the year when the rain was maximum,
  3. record the year when the sun was maximum,
  4. output this information on two lines of text:


Example


javac Hw3_1.java 
java Hw3_1 temperatures0.dat 
rain 1977 147.90
sun  1978 188.10


Lab #5


Full length following text