CSC 207 Grinnell College Fall, 2018
 
Algorithms and Object-Oriented Design
 

Lab: Eclipse, Java Style, Javadocs, and Input

Summary

This laboratory ties together several components of programming in Java:

Background Reading

Before working on this lab, be sure you have

Acknowledgments

Eclipse and GitHub

Summary: From many perspectives, Eclipse and GitHub do not work and play well with each other.

Altogether, this coupling of Eclipse and GitHub seems problematic. Thus, as Professor Rebelsky suggests, you are encouraged to place your work for a CSC 207 lab, project, or supplemental problem into two directories.

  1. Within your overall GitHub directory (e.g., ~CSC207/Git, create a subdirectory (e.g., javadocs-input) for programs related to this lab. The GitHub Classroom link for this lab is https://classroom.github.com/g/Cv0WyWct Use that link to create a team for this lab, set up a repository for this assignment, and connect that assignment with this subdirectory. With this done, a copy of each file (e.g., —.java will be placed in this subdirectory, and you will pull, add, commit, and push the files between this local repository and GitHub.

  2. Within Eclipse, create a package (e.g., javaDocsInput) for this lab. Although the package could be placed within a variety of structures, a natural choice would be to use the default directory (e.g., eclipse-workspace) and the default project (e.g., Examples). Within this package, create new classes as needed. You can edit and run these programs within Eclipse, just as you have done previously in this course.

Eclipse organizes your projects, packages, and classes in a hierarchical directory structure. In particular, source code for a class is placed in the following directory structure:

Eclipse Directory
Hierarchy

With files in these two structures, you could use the cp command to copy relevant files from one subdirectory to the other.

Javadocs and Java Style

  1. Create a new Class dabbadabba within your directory for this lab and paste the code dabbadabba into Eclipse. As you will see, this code is a syntactically correct-yet-poorly formatted Java program. It certainly does not conform to the CSC 207 Java Style Guide!

Working with File Input

File Grinnell-rainfall.dat contains daily rainfall totals for each day over several years. For example, the start of the current file begins:

Year  Day     Jan     Feb     Mar     Apr     May     Jun     Jul     Aug     Sep     Oct     Nov     Dec
2016    1    0.00    0.00    0.06    0.00    0.09    0.00    0.00    0.00    0.01    0.00    0.00    0.00
2016    2    0.11    0.00    0.00    0.15    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00
2016    3    0.01    0.00    0.00    0.84    0.00    0.00    0.00    0.53    0.00    0.23    0.01    0.00
2016    4    0.00    0.00    0.00    0.01    0.00    0.00    0.00    0.00    0.00    0.12    0.01    0.10
2016    5    0.00    0.00    0.00    0.59    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00
2016    6    0.00    0.00    0.42    0.00    0.00    0.00    0.00    0.00    0.00    1.02    0.00    0.00
2016    7    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.23    0.00    0.00
2016    8    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00
2016    9    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00
2016   10    0.46    0.00    0.00    0.05    1.52    0.00    0.04    0.00    0.00    0.85    0.00    0.00
2016   11    0.00    0.00    0.00    0.00    0.00    0.00    0.89    0.00    0.00    0.01    0.05    0.00
2016   12    0.00    0.00    0.00    0.00    0.00    0.00    0.52    0.00    0.00    0.01    0.19    0.00
2016   13    0.00    0.00    0.00    0.02    0.00    0.00    0.00    0.00    0.00    0.00    0.01    0.05
2016   14    0.00    0.00    0.00    0.16    0.00    0.14    0.00    2.47    0.00    1.12    0.03    0.00
2016   15    0.00    0.00    0.00    0.56    0.00    0.00    0.00    0.05    0.00    0.00    0.01    0.00
2016   16    0.47    0.00    0.00    0.00    0.00    0.31    0.00    0.05    0.70    0.00    0.00    0.00
2016   17    0.00    0.00    0.00    0.00    0.41    1.42    0.00    0.00    0.60    0.00    0.02    0.00
2016   18    0.00    0.00    0.00    0.01    0.00    0.00    0.48    0.00    0.21    0.00    0.15    0.00
2016   19    0.32    0.00    0.00    0.00    0.96    0.23    0.00    0.01    0.01    0.00    0.00    0.00
2016   20    0.04    0.34    0.00    0.00    0.22    0.00    1.15    0.21    0.00    0.00    0.00    0.00
2016   21    0.11    0.00    0.00    0.00    0.01    0.48    0.06    1.27    0.00    0.98    0.00    0.00
2016   22    0.01    0.00    0.00    0.00    0.00    0.09    0.00    0.05    0.00    0.27    0.00    0.00
2016   23    0.00    0.08    0.00    0.00    0.08    0.01    0.00    0.00    0.00    0.01    0.00    0.00
2016   24    0.10    0.15    0.33    0.00    0.00    0.00    0.00    0.03    0.00    0.00    0.00    0.00
2016   25    0.08    0.00    0.49    0.00    0.01    0.00    0.00    0.08    0.00    0.00    0.00    0.00
2016   26    0.00    0.00    0.14    0.30    0.20    0.00    0.00    0.00    0.58    0.00    0.00    0.00
2016   27    0.00    0.00    0.01    0.00    0.17    0.00    0.00    0.07    0.00    0.00    0.00    0.00
2016   28    0.00    0.00    0.00    0.28    0.00    0.25    0.00    0.01    0.00    0.00    0.00    0.00
2016   29    0.00    ---     1.06    0.51    0.00    0.00    0.00    0.01    0.00    0.09    0.00    0.00
2016   30    0.00    ---     0.03    0.77    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00
2016   31    0.00    ---     0.00    ---     0.00    ---     0.00    0.00    ---     0.00    ---     0.00
Y

In this file, data are given for some number of full years, largely copied from www.grinnellweather.com. As this printout indicates,

The particular file contains rainfall for 2016, 2017, and 2018, but the file might be updated at any time to include more or fewer years.

  1. Write a Java program that reads this file, determines the total rainfall for a year, and finds the two dates on which the largest rainfall occurred. (If more than two dates have the same maximum rainfall amount, the program may print any two of these dates. If one date has the maximum rainfail, and several dates are tied for second highest, then the program should print the date with the highest rainfall and any of the dates with the second highest.

Programing Notes

Submission Details


created 16 September 2018
last revised 17 September 2018
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.
[an error occurred while processing this directive]