BCIS JAVA HOMEWORK
BCIS 3680 Enterprise Programming Assignment 1 ‐ 1
BCIS 3680 Enterprise Programming Instructor: Dr. Andy Wu
Assignment 1
In this exercise, you will build a simple application that calculates the weekly average of
temperatures and then converts it from Fahrenheit to Celsius. The application works as follows:
1. When the application starts, it asks for Monday’s temperature:
2. After you enter Monday’s temperature, another dialog box appears, asking for Tuesday’s
temperature:
3. This process will continue for the other days in a week, with the last dialog box asking for
Sunday’s temperature:
4. Afterwards, the program calculates the weekly average and converts it to Celsius. It then displays
the results:
BCIS 3680 Enterprise Programming Assignment 1 ‐ 2
The above screenshot is just an example based on a set of temperatures I entered. When using your
application, the results should be dynamic and different for every different set of temperatures.
For now (in fact, for most of the semester) let’s assume a user will enter a legitimate value at the
blinking cursor. In other words, expect the user to enter a numeric value rather than “seventy”, a reasonable temperature value rather than 1000000000000000000000000, etc.
To write the application, you will apply what you have learned about methods and arrays. The
following are the specifications of the application:
1. Use a double array to store the seven daily temperature values.
2. Besides the main() method, write the following three methods. The data types of your parameter(s) and return value, if any, must match what are described in the following table. That is,
if a double value is specified here, declare your parameter/return type as such.
Method Name Function Input Output
calcAverage Calculates the weekly average temperature.
The seven daily temperatures stored in a double array.
The weekly average as a double value.
convertTemp Converts temperature from Fahrenheit to Celsius.
Fahrenheit value as a double. Celsius value as a float.
displayResults Displays a dialog box showing the calculation and conversion results.
1. Weekly average temperature in Fahrenheit as a double, and 2. Its Celsius equivalent as a float.
A dialog box showing the results.
3. The weekly average is a simple average of the seven daily ones, i.e., total divided by 7.
4. The formula for Fahrenheit to Celsius conversion is:
°C 9
32)(5) - (°F
5. To test the Fahrenheit to Celsius conversion, you can use some of the following values:
Description °F(user input, unformatted)
°C (result, formatted)
Water boiling point 212 100.00
Body temperature 98.6 37.00
Water freezing point 32 0.00
Mixing ice and ammonium chloride 0 -17.78
Convergence point -40 -40.00
Center of the sun 27000000 14,999,982.00
BCIS 3680 Enterprise Programming Assignment 1 ‐ 3
6. Note that the Fahrenheit and Celcius output are precise to two decimal places. To perform this
formatting, use the DecimalFormat class. Declare a DecimalFormat object and use its related method if necessary.
7. You must use method names exactly as listed above. Failure to do so may cause point deduction.
You may use names of your choice for local variables in the methods. However, you should follow
the proper Java naming convention.
Submission
35 points. Due at 11:59 PM on Sunday, February 9, 2014
Below are steps to follow for submission:
Submit your assignments only through Blackboard. Assignments submitted to the instructor or grader by email will NOT be graded, unless you
are instructed to do so.
Create a folder and name it 3680‐HW1‐YourLastName‐YourFirstName. Copy both your source code file (.java) AND the compiled file (.class) file to the folder.
Zip the folder into 3680‐HW1‐YourLastName‐YourFirstName.zip (RAR is fine too). Submit the zip file as an attachment on Blackboard. Before the assignment is due, you may resubmit your work for unlimited times. Simply
attach a new version of your assignment. Only the attachment with the latest timestamp will
be graded.
Failure to comply with these requirements will cause point deduction.