The goal of this assignment is to produce a program using the software development process we have learned in class and to write a program that interacts with the user.
As last time, move into your cs241
directory.
Make a directory for this assignment, and change into it.
> cd cs241 > mkdir assign3 > cd assign3
Open a file called TempConvert.java in Xemacs.
> xemacs TempConvert.java &
You are to write a program which will convert temperature readings from Fahrenheit to Celsius and calculate an average temperature. Here's the program's specification:
The program should prompt the user for five temperatures in Fahrenheit, and then display each of the temperatures in Celsius and an average temperature, in Celsius. The inputed temperature should be integers, but the output must be real numbers.
A run of the program should look something like this:
Please enter a temperature in Fahrenheit--> 72 Please enter a temperature in Fahrenheit--> 32 Please enter a temperature in Fahrenheit--> 0 Please enter a temperature in Fahrenheit--> 100 Please enter a temperature in Fahrenheit--> 212 72 converts to 22.22222222222222 32 converts to 0.0 0 converts to -17.77777777777778 100 converts to 37.77777777777778 212 converts to 100.0 Average temp: 28.444444444444446
Practice the development process we learned in class Friday. Think through the specification, and then figure out an algorithm to solve it. Once you think you know what to do, write the documentation heading, and write a program that implements your algorithm. Then work through the compiler errors (don't be discouraged if you get errors-- because you certainly will get them!) and test the program until you're sure it works, documenting as you go along.
The formula for converting from Fahrenheit to Celsius is
DegreesCelsius = 5 * (DegreesFahrenheit - 32) / 9
Remember, to prompt the user and read in an integer, use
DocsIO.readint("...")
.
Follow the style and documentation principles we've talked about in class-- document each variable declaration, variables should be in lowercase (unless you use internal capitalization to separate words), etc. Use Xemacs's tabbing feature to make the lines aligned nicely. See the course style principles for a review and example; only the first six rules apply to us so far.
Turn in the same way you did last time. Here are the instructions again:
> script assign2script
> rm *.class
cat
command.
> cat TempConvert.java
> javac TempConvert.java
> java TempConvert
> exit
> cd
and start the mail program "pine."
> pine
You can exit pine by pressing "Q" for "quit".
DUE: Friday, Jan 28, at 5:00 PM.