Docsity

CS 101 Homework 1: Heat Index Calculation - Prof. James Cohoon, Assignments of Computer Science

Toggle sidebar
bg1
CS 101 Unpledged
CS 101 Page 1 of 2 Spring 1998
Homework 1
Assigned in Laboratory 2
Due Start of Laboratory 3
Please perform the following activities. This assignment is unpledged. However, you may not
work with anyone else on this first assignment. You are allowed to talk with others, but your work
must be your own.
Objective
The objective of this assignment is twofold: to practice coding programs that do interactive input
and output, and to make sure that you understand how to write simple programs that compute use-
ful things. Good programmers often write small programs to do a short, useful computation.
Problem
Produce a program that computes and displays the heat index (perceived temperature) from two
user-supplied floating point values: a Fahrenheit temperature T and a relative humidity percentage
R. There are several slightly different formulas for computing heat index. The formula we shall
use comes from USA Today’s weather website at http://www.usatoday.com.
HeatIndex = -42.379 + 2.04901523T + 10.14333127R - 0.22475541TR - 6.83783e-03(T2)
- 5.481717e-02(R2) + 1.22874e-03(T2R) + 8.5282e-04(TR2) - 1.99e-06(T2R2)
Besides displaying the heat index value, your program should supply a legend that suggests that
its user take care when the heat index is greater than 90 and even more so when the heat index
exceeds 110.
Remember to prompt the user for the inputs, then echo them in a meaningful fashion.
All floating point values should use C++’s double representation.
Notes
Please review the CS101 style sheet before starting on the assignment. Be sure to use the standard
header (i.e., your name, section number, etc.) in your program. The standard header for all our
programs (unless instructed otherwise) will contain the following information:
// Programmer:
// Student ID:
// E-mail:
// CS101 Lab Section:
// CS 101 Lab time:
You should submit your program electronically before the start of laboratory 3. See the CS101
website (http://www.cs.virginia.edu/cs101) for information on how to do this. Your program must
be called hw01.cpp.
You should also turn in a hardcopy (printout) at the beginning of your laboratory when the pro-
gram is due. This hardcopy is due at the beginning of laboratory 3.
pf2

Partial preview of the text

Download CS 101 Homework 1: Heat Index Calculation - Prof. James Cohoon and more Assignments Computer Science in PDF only on Docsity!

CS 101 Unpledged

CS 101 Page 1 of 2 Spring 1998

Homework 1

Assigned in Laboratory 2

Due Start of Laboratory 3

Please perform the following activities. This assignment is unpledged. However, you may not work with anyone else on this first assignment. You are allowed to talk with others, but your work must be your own.

Objective

The objective of this assignment is twofold: to practice coding programs that do interactive input and output, and to make sure that you understand how to write simple programs that compute use- ful things. Good programmers often write small programs to do a short, useful computation.

Problem

Produce a program that computes and displays the heat index (perceived temperature) from two user-supplied floating point values: a Fahrenheit temperature T and a relative humidity percentage R. There are several slightly different formulas for computing heat index. The formula we shall use comes from USA Today ’s weather website at http://www.usatoday.com.

HeatIndex = -42.379 + 2.04901523 T + 10.14333127 R - 0.22475541 TR - 6.83783e-03( T 2 )

  • 5.481717e-02( R 2 ) + 1.22874e-03( T 2 R ) + 8.5282e-04( TR 2 ) - 1.99e-06( T^2 R 2 )

Besides displaying the heat index value, your program should supply a legend that suggests that its user take care when the heat index is greater than 90 and even more so when the heat index exceeds 110.

Remember to prompt the user for the inputs, then echo them in a meaningful fashion.

All floating point values should use C++’s double representation.

Notes

Please review the CS101 style sheet before starting on the assignment. Be sure to use the standard header (i.e., your name, section number, etc.) in your program. The standard header for all our programs (unless instructed otherwise) will contain the following information:

// Programmer: // Student ID: // E-mail: // CS101 Lab Section: // CS 101 Lab time:

You should submit your program electronically before the start of laboratory 3. See the CS website ( http://www.cs.virginia.edu/cs101 ) for information on how to do this. Your program must be called hw01.cpp.

You should also turn in a hardcopy (printout) at the beginning of your laboratory when the pro- gram is due. This hardcopy is due at the beginning of laboratory 3.

CS 101 Unpledged

CS 101 Page 2 of 2 Spring 1998

The grading criteria for this assignment can also be found at our class website.

A sample run of the type of output that your program should produce is given below. Observe the legend, nice prompts, and labeled output. The phrasing that you use does not need to exactly mimic this sample, but it does need to be of similar quality.