CST 180 - Function Lab 5

PART 5A:  Class Demo: Rewrite Average Speed Program
Change documentation to reference this lab activity.
Add a function to calculate the speed:

  • Function Name:  mph( )
  • Arguments:  Pass doubles for miles and hours
  • Return Value:  The average speed (also a double)
  • Prototype:  double mph(double, double);
TEST DATA SETS:
 
Miles Driven
Driving Time
MPH
282.6
4.5
62.8
1741.0
32.0
 
31.8
.6
 
Submit:
  • No submission required. Used for class demonstration.


PART B:  Rewrite Lab 4 (Pay Calculation Program)

Add these functions:

  • Function Name:  display( )
    • Arguments:  None
    • Return Value:  None
    • Prototype:  void display(void);
    • Action:  Display name and lab number
  • Function Name:  code_not_valid( )
    • Arguments:  pay code (a char)
    • Return Value:  true, if bad code; false, if good code
    • Prototype:  bool code_not_valid(char);
    • Action:  Use do/while loop in main to enter pay code
      • Test T/F value returned by function to see if another iteration is necessary
  • Function Name:  get_grossPay( )
    • Arguments: payRate and hoursWorked (pass by value)
    • Return Value:  grossPay (assign to gPay variable in main())
    • Prototype:  double get_grossPay(double, double);
    • Action:  Determine gross pay amount..

 

Program Interaction:

  • These are the inputs and the expected outputs.
  • Your program determines Pay Rate and Pay Amount based on user inputs and internal processing.
Assignment 5B Programmed by yourname here
Enter Employee #, Pay Code, Hours:
1032864 M 41
Pay Rate:  $??.??        Pay Amount: $???.??
Another employee to process (Y/N)?  y
Enter Employee #, Pay Code, Hours:
1171955 T 38
Pay Rate:  $??.??        Pay Amount: $???.??
Another employee to process (Y/N)?  y
Enter Employee #, Pay Code, Hours:
1224096 O 45
Pay Rate:  $??.??        Pay Amount: $???.??
Another employee to process (Y/N)?  y
Enter Employee #, Pay Code, Hours:
1234567 N 40
INVALID PAY CODE
Pay Rate:  $??.??        Pay Amount: $???.??
Another employee to process (Y/N)?  n

Number of Employees Processed: ??   Total Payroll:  $????.??

 Normal Job Termination

 

Submit:
  • A single turn-in document with source code and screenshot of program execution.
Return to TOP

! You are using a version 4 browser or older. If you are experiencing any problems with scrolling, please reload the page.