Assignment 2  CS 1711   Fall, 1999/2000


Due: Friday, October 22

The detailed instructions on handing in assignments are located on the course Web page.  Make sure to read the programming standards and course ethics material before attempting the assignment

Question 1

A Canadian building supply company needs to be able to convert "English"  dimensioned lumber products to metric area. Write a free function which accepts four real parameters ( the first two represent the width in feet and inches, and  the second the length in feet and inches) and returns the number of square meters. The prototype function should be declared as:
        double englishToMetricArea (double width_ft, double width_in, double length_ft, double length_in);

Test the function englishToMetricArea by including it in a short programme which prompts the user for the two width dimensions (feet, inches) and the length dimensions (feet, inches) and displays the area of the item in square meters.

Sample run

Program to convert English units into metric area.

Feet and inches of the width (separated by spaces) > 1 0
Feet and inches of the length(separated by spaces) > 1 0

------------------------------------------------
The metric area of the item is .09 square meters.

File name:

area.cpp

Question 2 (variant of problem 47, p 201, text)

Write a program that uses strings to read a person's last name, first name, and a character "f" or "m" (gender). Output the name with the title "Ms" for female and "Mr" for male. Run the program three times using as input
McCarthy Tom   m
Dong     Jeri  m
<yourname>    <your sex>
 

Sample run

Program to display a  formal name
Enter last name, first time, and gender (m/f) separated by spaces
McCarthy Tom   m
----------------
Mr Tom McCarthy

File name:

namesex.cpp

Question 3

Write a program that prompts the user to enter integers, on a single line, separated by spaces, and terminated by a zero . At that point, the program will display the sum of all the positive integers entered.

Sample run

Program to sum positive integers. 
Enter integers on a single line, separated by spaces, and terminated with a zero
Integer>23   -4   4     0
The sum of the positive integers is 27.

File name:

sumints.cpp