CprS 157 Schedule
CprS 157 Class 2
CprS 157 Class 4

Numeric Datatypes, Expressions, and Formatted Output
Chapter 3 - Class 3


Reading Some Sample Programs

// FreezeBoil program
// This program computes the midpoint between
// the freezing and boiling points of water

// HouseCost program
// This program computes the cost per square foot of
// living space for a house, given the dimensions of
// the house, the number of stories, the size of the
// nonliving space, and the total cost less land

// Walk program
// This program computes the mileage (rounded to tenths of a mile)
// for each of four distances between points in a city, given
// the measurements on a map with a scale of one inch equal to
// one quarter of a mile

Modify freezeBoil.cpp so that it uses a function to compute the average of two floating-point numbers. Modify houseCost.cpp so that it uses a function to round off floating-point numbers.

Programming Exercises

  Solve these exercises in class, to your own satisfaction. Demonstrate your solutions to the instructor or to the class TA. There is nothing to hand in from this activity.

Homework For Chapter 3

  The "Hello, World!" program is surely the most often rewritten C++ program, and the temperature conversion program might be a close second. Here we go! Be the first kid on your block to rewrite the temperature conversion program in C++. Once you have it working correctly, let's see if we can organize things so that your program takes its input from the keyboard. Enhance your program so that it also converts its input into degrees Kelvin. Strive for clear and elegant solutions to your programming exercises. Correctly and attractively formatting your code helps to convey the structure and logic of your work to your readers. Drop an electronic copy of your program into the CS157 drop box before class time, 9:30 AM, next Tuesday. Use the file-naming conventions we have developed in class.