Java
Lab 7: Loops and Vectors
Due Date: Monday November 12 at 11:59 pm
Assignment
Build a TemperatureList class to process a file of
temperatures.
This class will read the temperatures into a Vector from a file and
report the following data to the monitor.
-
The number of days (temperatures) processed
-
the number of days above the average temperature (and the average temperature)
-
the number of days below the average temperature (and the average temperature)
-
Which pair of adjacent days shows the greatest change in temperature and
the difference in temperature between those days
-
The days and corresponding temperatures of the above pair
-
The day with the lowest temperature and what the lowest temperature was
-
You must design and use a class. The only data field you may have in your
class is a Vector of int.
-
Your decomposition (breakdown into methods) will be part of your grade.
Use the FileInput and the ConsoleInput
classes to process the file and send the results to the monitor.
Checking your results
Run the executable on the both test files (temps1.txt and
temps2.txt)
and compare your results with the executable.
Getting Started
Download the lab7.zip file. Save the zip file to your C:\Temp directory
and unzip the files. Open the directory Temperatures. You should see the
following files:
-
Temperatures.mcp (the project file for this Java application)
-
Scenario.java (a source file for this Java application)
-
This is the driver class
-
This class creates the necessary objects, and initiates the appropriate
member functions to solve the problem
-
You will also be responsible for completing this file, so that the output
models the executable
-
TemperatureList.java (a source file for this Java application)
-
This is the class file
-
You will be responsible for creating the instance variables and member
functions of this class
-
ConsoleInput.java (a source file for this Java application)
-
FileInput.java (a source file for this Java application)
-
lab7.exe (an executable file that demosntrates what your
program should do if you have written it successfully)
-
temps1.txt and temps2.txt, the files that
contain the temperatures
-
results1.txt and results2.txt, the files
that show what your output should look like
-
a copy of this .html file
Handing in your Solution
Your solutions should be in the form of .zip files. When we grade your
solution we will unzip the folder and execute the project. If your project
does not run you will lose the execution points for that lab.
Your Solution zip file must contain all the files in your projects
Your teaching assistants will show you how to zip up the files for submission.
Instructions are also in the Tutorial
document that is available
Click on this link to Submit
your zip file
lab courtesy of
Don Slater |