UMBC CMSC 202
UMBC CMSC 202 CSEE | 202 | current 202

CMSC 202 Fall 2003
Project 1

Your First C++ Program

Assigned Wed Sept. 17, 2003
Program Due Tues Sept 23, 2003 at 11:59pm
Updates 20 Sept 2003 -- A note to help clarify the sample output was added. Also, in the third example output, the ending number of pounds was incorrectly shown as 10; its been changed to 100 which is the correct value.

Objectives


Project Description

In this project, you will display a table that shows the conversion of pounds to kilograms and grams. Your program will prompt the user for three inputs -- starting number of pounds, ending number of pounds, and the incremental number of pounds. Your display will consist of one row for each incemental value between the starting number of pounds and the ending number of pounds. A table heading and column labels are also required. See the
sample output below.

Your program must contain the following functions. The code for these functions must be found in Pounds.cpp. Their prototypes and function header comments must be found in Pounds.h which is included in Proj1.cpp. The names of the functions are left to you, but must follow our coding standards. The parameters and return type for each function are also left to you, but you must carefully consider how each parameter should be passed. Deductions will be made for parameters which are not passed using the best method. Other functions are permitted as you see fit.

  1. A function that prints a suitable greeting to the user.
  2. A function that gets the required input from the user.
    This function should prompt the user for the starting, ending and incremental number of pounds as integers.
    Input verification of all inputs are required. It's up to you to consider all bad user inputs. Your function should reprompt the user when a bad input is detected.
  3. A function that converts pounds to kilograms including the fractional kilos.
    For example, this function converts 100 pounds to 45.360 kilograms.
  4. A function that converts pounds to an integral number of kilograms and grams.
    For example, this function converts 100 pounds to 45 kilograms and 359 grams.
  5. A function that produces the required output.

Sample Output

This sample output is provided to show you a reasonable output format which satisfies the project requirements. It is not necessary that you follow this format exactly, but whatever format you choose must provide all required data which must be presented in columns. A title for the table and headings for each column are required.

Since we have not yet studied formatted output (other than how to output values with a fixed number of decimal places), using TAB and space characters to obtain the column spacing is permitted.

Clarification added 20 Sept.

In this output, the first column is the number of pounds.
The second and third columns go together in that 10000 pounds = 4535 Kg + 970 gram.
The last column is the number of pounds covnverted only to kilograms. I.e. 10000 pounds = 4535.970 kilograms.
Depending on how you did your calculation and printing, there may be a difference of 1 between the grams and the fractional part of the 4th column.

linux3[104] Proj1 Welcome to our pound conversion program Input the starting number of pounds: 10000 Input the ending number of pounds: 20000 Input the incremental number of pounds: 1000 Pound to Kilogram Conversion Table Pounds Kgs Grams Kgs 10000 4535 970 4535.970 11000 4989 567 4989.567 12000 5443 164 5443.164 13000 5896 761 5896.761 14000 6350 358 6350.358 15000 6803 955 6803.955 16000 7257 552 7257.552 17000 7711 149 7711.149 18000 8164 746 8164.746 19000 8618 343 8618.343 20000 9071 940 9071.940 linux3[105] Proj1 Welcome to our pound conversion program Input the starting number of pounds: 100 Input the ending number of pounds: 200 Input the incremental number of pounds: 20 Pound to Kilogram Conversion Table Pounds Kgs Grams Kgs 100 45 359 45.360 120 54 431 54.432 140 63 503 63.504 160 72 575 72.576 180 81 647 81.647 200 90 719 90.719 linux3[105] Proj1 Welcome to our pound conversion program Input the starting number of pounds: 10 Input the ending number of pounds: 100 Input the incremental number of pounds: 7 Pound to Kilogram Conversion Table Pounds Kgs Grams Kgs 10 4 535 4.536 17 7 711 7.711 24 10 886 10.886 31 14 61 14.062 38 17 236 17.237 45 20 411 20.412 52 23 587 23.587 59 26 762 26.762 66 29 937 29.937 73 33 112 33.113 80 36 287 36.288 87 39 462 39.463 94 42 638 42.638 linux3[105]

Free Advice and Information

  1. There are 2.2046 pounds per kilogram.
  2. There are 1000 grams per kilogram.
  3. The math function floor( ) can be used to round down (i.e remove the decimal part of a floating point number to get the just the integer part). See page 96 of the text.
  4. Review the class notes on the different methods of passing parameters. Each is best for a different situation.
  5. Be sure to name your files Proj1.cpp, Pounds.cpp and Pounds.h. Otherwise, you will have to modify the makefile we provide.
  6. Your program will be tested with a variety of good and bad inputs. You should spend considerable creating input combinations that will thoroughly test your program.
  7. Use incremental development.

Project Design Assignment

There is no project design assignment for this project.

Project Makefile

The "make" utility is used to help control projects with large numbers of files. It consists of targets, rules, and dependencies. You will be learning about make files in discussion. For this project, the makefile will be provided for you. You will be responsible for providing makefiles for all future projects. Copy the file

/afs/umbc.edu/users/d/e/dennis/pub/CMSC202/p1/Makefile to your directory.

When you want to compile and link your program, simply type the command make or make Proj1 at the Linux prompt. This will compile Proj1.cpp, Pounds.cpp and create the executable named Proj1

In addition to creating your project executable, make can be used for maintaining your directory. Typing make clean will remove any extraneous files in your directory, such as .o files and core files. Typing make cleanest will remove all .o files, core, Proj1, and backup files created by the editor. More information about these commands can be found at the bottom of the makefile.


Grading

The grade for this project will be broken down as follows. A more detailed breakdown will be provided in the grade form you recieve with your project grade.

85% - Correctness

This list may not be comprehensive, but everything on this list will be verified by the graders.

15% - Coding Standards

Your code adheres to the CMSC 202 coding standards as discussed and reviewed in class.
In particular, since this is your first C++ program, pay attention to the list below. Graders will check all applicable items in the coding standards.
  1. Your file header comments
  2. Your function header comments
  3. Function and variable names
  4. In-line comments
  5. Code readability
  6. Limiting variable scope

Project Submission

Assuming you've used the recommended file names, then to submit your project, type the command submit cs202 Proj1 Proj1.cpp Pounds.cpp Pounds.h Makefile The order in which the files are listed doesn't matter. However, you must make sure that all files necessary to compile your project (using the makefile) are listed.

You can check to see what files you have submitted by typing

submitls cs202 Proj1

More complete documentation for submit and related commands can be found here.

Remember -- if you make any change to your program, no matter how insignificant it may seem, you should recompile and retest your program before submitting it. Even the smallest typo can cause compiler errors and a reduction in your grade.

Avoid unpleasant surprises!
Be sure to use the submitmake and submitrun utilities provided for you to compile, link and run your program after you've submitted it.


Last Modified: Sunday, 21-Sep-2003 11:20:59 EDT