Skip to content

Instantly share code, notes, and snippets.

Created March 1, 2013 22:19
Show Gist options
  • Save anonymous/7b0cf0269e30f3499f1f to your computer and use it in GitHub Desktop.
Save anonymous/7b0cf0269e30f3499f1f to your computer and use it in GitHub Desktop.
/* Score: ___ / 50
* Comments/Grading Criteria (50% output; 50% coding)
* 1) code the enterParcelWeight() function
* 2) code the calculateDeliveryCharge(double) function
* 3) code the displayDeliveryCharge(double, double) function
* 4) code the incomplete printHeadings() function
*
*
* CIS 276 Introduction to C/C++ Programming
* Chuck Nelson, Professor
*
* Student Information (please complete ? below)
* Name: ?
* RVC Email: s???????@student.rockvalleycollege.edu
* Class Information
* Section: ?
* Assignment Information
* Project Name: U04_DeliveryCharge
* Source Name: U04_DeliveryCharge.cpp
* U04_DeliveryChargeMain.cpp
*---------------------------------------------------------------------
*
* Sample Program Run
Project/program name: U04_DeliveryCharge
by
<your name here>
Calculating parcel delivery charges
Enter parcel weight: 20
Parcel weight: 20.00
Delivery charge: $ 49.00
Run program again? (y/n): y
...........................
Calculating parcel delivery charges
Enter parcel weight: 6
Parcel weight: 6.00
Delivery charge: $ 14.70
Run program again? (y/n): y
...........................
Calculating parcel delivery charges
Enter parcel weight: 5
Parcel weight: 5.00
Delivery charge: $ 14.25
Run program again? (y/n): y
...........................
Calculating parcel delivery charges
Enter parcel weight: 4
Parcel weight: 4.00
Delivery charge: $ 11.40
Run program again? (y/n): y
...........................
Calculating parcel delivery charges
Enter parcel weight: 2.5
Parcel weight: 2.50
Delivery charge: $ 7.13
Run program again? (y/n):
*/
Notice how the program heading is displayed only once but the subtitle (Calculating parcel delivery charges) is repeated with each program loop iteration. Also, notice the divider dots!
When you first create your correctly named project, add the two .cpp files to the project, compile, build and run. The initial output should be like:
Project/program name: U04_DeliveryCharge
by
<your name here>
Calculating parcel delivery charges
Run program again? (y/n):
After you correctly code the program enter function, the output should be like:
Project/program name: U04_DeliveryCharge
by
<your name here>
Calculating parcel delivery charges
Enter parcel weight: 7.5
Run program again? (y/n):
After you correctly code the program calculation function, the output should be like (screen output is exactly like input but if you run in debugger, check the local variables values for the parcel weight & delivery charge).
Project/program name: U04_DeliveryCharge
by
<your name here>
Calculating parcel delivery charges
Enter parcel weight: 7.5
Run program again? (y/n):
After you correctly code the program display function, the output should be like:
Project/program name: U04_DeliveryCharge
by
<your name here>
Calculating parcel delivery charges
Enter parcel weight: 7.5
Parcel weight: 7.50
Delivery charge: $ 18.38
Run program again? (y/n):
/*-----------------------------------------------------------------
Overview
In this program, you will code three functions, their prototypes, and their calls.
The source code has areas specified where you are to enter your code.
Note: DO NOT ALTER THE man() FUNCTION !
Task List - Step #1
/* Function: enterParcelWeight() ***********************************
* parameter(s): none
* return: parcelWeight : double (return by value)
* NOTE: for grading, no weights over 20 pounds will be used
*/
code the enterParcelWeight() function
code the enterParcelWeight() function prototype
-this is done in the doit() function
code the enterParcelWeight() function call
-this is done in the doit() function
change: #define ENTER 0
to #define ENTER 1
compile, debug, and when error free, run.
the enterParcelWeight() should now work; there will not yet be any processing nor output.
[NOTE: be sure Step #1 is error free before starting Step #2]
Task List - Step #2
/* Function: calculateDeliveryCharge(double) *******************
* parameter(s): parcelWeight : double
* return: deliveryCharge : double
*/
code the calculateDeliveryCharge(double) function
code the calculateDeliveryCharge(double) function prototype
-this is done in the doit() function
code the calculateDeliveryCharge(double) function call
-this is done in the doit() function
change: #define CALC 0
to #define CALC 1
compile, debug, and when error free, run.
the calculateDeliveryCharge(double) should now work; there will input and processing, but no output
NOTE: you can verify the accuracy of your calculate function by using the debugger and check the deliveryCharge variable in the locals tab..
[NOTE: be sure Step #1 is error free before starting Step #2]
Task List - Step #3
/* Function: displayDeliveryCharge() ******************************
* parameter(s): parcelWeight:double, deliveryCharge:double
* return: none
* parcel weight and delivery charge require 2 decimal places
* parcel weight and delivery charge decimal points must line up
* delivery charge requires the symbol $ placed correctly
*/
code the displayDeliveryCharge(double, double) function
code the displayDeliveryCharge(double, double) function prototype
-this is done in the doit() function
code the displayDeliveryCharge(double, double) function call
-this is done in the doit() function
change: #define DISPLAY 0
to #define DISPLAY 1
compile, debug, and when error free, run.
the displayDeliveryCharge(double, double) should now work; there will input and processing and output!
Task List - Step #4
/* Function: printHeadings() ***********************************
* return: void
*
* TODO: replace <your name here>
* with your first name and last name
*/
code the changes needed in the printHeadings() function
TODO: replace <your name here>
with your first name and last name
compile, debug, and when error free, run.
the program should now be complete and your output should match the sample output above.
format your source code that tabbing, indentation, spelling, blank lines for readabiltiy, etc., are all present.
see codingStyle.txt for standards.
-----------------------------------------------------------------*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment