OBJECTIVE:
This assignment is designed to give you practice using
call-by-reference paramater passing and
writing programs with user-defined
functions.
THE ASSIGNMENT:
Your assignment is to write a program
that converts metric length (meters, centimeters) input
by the user to English units (feet, inches).
To do this you will need to write three functions, you MUST use
parameters as shown:
1. //explains program to user and directs them to enter
appropriate values.
void input(double& meters);
2. //makes converson from metric to English units
void convert(int& feet, double&
inches, double meters);
//it will make use of the following global constants
const double METERS_PER_FOOT = 0.3048;
const double INCHES_PER_FOOT = 12.0;
3. //handles the output as shown in the sample script below
void output(int feet, double inches, double
meters);
INPUT AND OUTPUT:
The program must prompt the user to input a number of meters as a real
number.
The program must convert the input to English units and report the
value to the user.
After the results are reported the program must ask the user if they
would like to continue and either repeat or exit, depending on the
user's choice.
How it should look when you run the program:
mmartin@cs.csustan.edu:(~/cs1500/solo4)
g++ solo4.cpp
mmartin@cs.csustan.edu:(~/cs1500/solo4)
a.out
Enter a
number of meters as a double
22
The value of
meters, centimeters 22.00 meters converted to English measure is 72
feet, 2.14 inches
Y or y
continues, any other character quits
y
Enter a
number of meters as a double
45
The value of
meters, centimeters 45.00 meters converted to English measure is 147
feet, 7.65 inches
Y or y
continues, any other character quits
q
WHAT TO
TURN IN:
Here is the list of things you have to turn in:
- At the start of class on the due
date place the following item on the "counter" in
front of me:
- a hardcopy (printed listing) of your program (the C++ source
code). Make sure all the code is properly formatted and that it all
shows on the paper.
- Before midnight on the the due
date upload the following to the Homework Submission
System:
- A copy of the source code (C++ code) (be sure your name is
in the comment section at the beginning of the program), named sprog4.cpp
- and a (filtered) script showing a test run of the program,
named sprog4.script
DUE DATES:
For the due dates, see
the class schedule.