5 Replies - 1508 Views - Last Post: 28 July 2012 - 07:11 PM Rate Topic: -----

#1 studalicious16  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 12-November 10

Compute Employee Gross pay and Net Pay

Posted 27 July 2012 - 07:09 PM

I am having problems with my functions. The GrossPay and Netpay functions are not displaying the right information. I am also getting the following warning messages. I am unsure of how to get this program to operate as needed. Any suggestions would be great!

Warning W8070 ModularPay.c 69: Function should return a value in function Calc_GrossPay
Warning W8070 ModularPay.c 76: Function should return a value in function Calc_NetPay
Warning W8065 ModularPay.c 83: Call to function 'Id' with no prototype in function main
Warning W8065 ModularPay.c 84: Call to function 'Rate' with no prototype in function main
Warning W8065 ModularPay.c 85: Call to function 'Regular' with no prototype in function main
Warning W8065 ModularPay.c 86: Call to function 'Overtime' with no prototype in function main
Warning W8065 ModularPay.c 87: Call to function 'Calc_GrossPay' with no prototype in function main
Warning W8065 ModularPay.c 88: Call to function 'Calc_NetPay' with no prototype in function main






/*  Computes Employee monthly gross pay, net pay, and parking */


#include <stdio.h>   /* allows printf and scanf functions */
#include <stdlib.h>   /* provides function abs */
#include <string.h>  
#include <math.h>
#define Parking 10
#define Tax .30


	/*Declare variables */
   double employee_id;
   double HourlyRate;
   double RegHours;
   double OverTimeHours;
   double GrossPay;
   double NetPay;

   

/* Declare functions */
   void Id();
   void Rate();
   void Regular();
   void Overtime();
   float Calc_GrossPay();
   float Calc_NetPay();
	
	  void Id()
   {
   /*  Get Employees Id */
      printf("Enter your Employee Identification \n");
      scanf("%d",&employee_id);
      printf(" Your Employee Identification is: %d \n", employee_id);
   			  
   }
   void Rate()
   {
   /* Get Employees Hourly Rate */
      printf("Enter your hourly Rate\n");
      scanf("%lf",&HourlyRate);
      printf("Your Hourly Rate is: %lf \n", HourlyRate);
   			  
   }
   void Regular()
   {
   /* Get Employees Regular hours */
      printf("How many regular hours do you have\n");
      scanf("%d",&RegHours);
      printf("Your regular hours are: %d\n", RegHours);
   				
   }
   void Overtime()
   {
   /* Get Employees overtime hours */
      printf("How many overtime hours do you have for the week\n");
      scanf("%d",&OverTimeHours);
      printf("Your total overtime hours are: %d \n", OverTimeHours);  
   			
   }
   float Calc_GrossPay()
   {
      GrossPay = RegHours + HourlyRate + OverTimeHours * (HourlyRate * 1.5) ;
   
      printf("Your Gross Pay is:%f \n", GrossPay);
      
     
   }
   float Calc_NetPay()
   {
         NetPay = ((GrossPay * Tax)- Parking);
     scanf("%f", &NetPay);
      printf("Your Total Net Pay is: %f \n", NetPay);
     
   }

   int main(void)
   {
   	
      printf("Welcome to Super Supermarket Employee Payroll System\n");
   	
      Id();
      Rate();
      Regular();
      Overtime();
      Calc_GrossPay();
      Calc_NetPay();
   	
      return(0);
   }




Is This A Good Question/Topic? 0
  • +

Replies To: Compute Employee Gross pay and Net Pay

#2 jimblumberg  Icon User is online

  • member icon

Reputation: 3048
  • View blog
  • Posts: 9,282
  • Joined: 25-December 09

Re: Compute Employee Gross pay and Net Pay

Posted 27 July 2012 - 07:48 PM

I suggest that you read the excellent function tutorials that I have linked in my signature.

I also suggest you stop using the global variables and pass the required variables to and from your functions.

Jim

This post has been edited by jimblumberg: 27 July 2012 - 07:49 PM

Was This Post Helpful? 0
  • +
  • -

#3 studalicious16  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 12-November 10

Re: Compute Employee Gross pay and Net Pay

Posted 28 July 2012 - 12:45 AM

I am having trouble calculating the net and gross pay. My output is coming out wrong. I also have many warning messages that I am unsure of. Any help would be greatly appreciated.
/*  Computes Employee monthly gross pay, net pay, and parking */


#include <stdio.h>   /* allows printf and scanf functions */
#include <stdlib.h>   /* provides function abs */
#include <string.h>  
#include <math.h>
#define Parking 10
#define Tax .30


	/*Declare variables */
   double employee_id;
   double HourlyRate;
   double RegHours;
   double OverTimeHours;
   double GrossPay;
   double NetPay;

   

/* Declare functions */
   void Id();
   void Rate();
   void Regular();
   void Overtime();
   void Calc_GrossPay();
   void Calc_NetPay();
	
	  void Id()
   {
   /*  Get Employees Id */
      printf("Enter your Employee Identification \n");
      scanf("%d",&employee_id);
      printf(" Your Employee Identification is: %d \n", employee_id);
   			  
   }
   void Rate()
   {
   /* Get Employees Hourly Rate */
      printf("Enter your hourly Rate\n");
      scanf("%d", &HourlyRate);
      printf("Your Hourly Rate is: %d\n", HourlyRate);
   			  
   }
   void Regular()
   {
   /* Get Employees Regular hours */
      printf("How many regular hours do you have\n");
      scanf("%d",&RegHours);
      printf("Your regular hours are: %d\n", RegHours);
   				
   }
   void Overtime()
   {
   /* Get Employees overtime hours */
      printf("How many overtime hours do you have for the week\n");
      scanf("%d",&OverTimeHours);
      printf("Your total overtime hours are: %d\n", OverTimeHours);  
   			
   }
   void Calc_GrossPay()
   {
	 double GrossPay;
      GrossPay = RegHours + HourlyRate + OverTimeHours * (HourlyRate * 1.5) ;
   
      printf("Your Gross Pay is:%d + %d + %d * %d * 1.5 \n", RegHours,HourlyRate,OverTimeHours,HourlyRate);
      
     
   }
   void Calc_NetPay()
   {
         NetPay = ((GrossPay * Tax)- Parking);
     scanf("%f", &NetPay);
      printf("Your Total Net Pay is: %f \n", NetPay);
     
   }

   int main(void)
   {
   	
      printf("Welcome to Super Supermarket Employee Payroll System\n");
   	
      Id();
      Rate();
      Regular();
      Overtime();
      Calc_GrossPay(GrossPay);
      Calc_NetPay();
   	
      return(0);
   }
 


Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3040
  • View blog
  • Posts: 4,556
  • Joined: 08-June 10

Re: Compute Employee Gross pay and Net Pay

Posted 28 July 2012 - 02:56 AM

Does this actually have anything to do with Objective-C, or did you post this in the wrong section?
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5667
  • View blog
  • Posts: 22,511
  • Joined: 23-August 08

Re: Compute Employee Gross pay and Net Pay

Posted 28 July 2012 - 03:05 AM

Moved to C and C++.

Quote

My output is coming out wrong.


What's the output? What do you expect?

Quote

I also have many warning messages that I am unsure of


So copy and paste them here! Don't expect us to be psychic!

EDIT: And then I found your duplicate in C and C++ and merged it in. Why did you create a NEW topic in an unrelated forum?
Was This Post Helpful? 0
  • +
  • -

#6 #define  Icon User is offline

  • Duke of Err
  • member icon

Reputation: 977
  • View blog
  • Posts: 3,393
  • Joined: 19-February 09

Re: Compute Employee Gross pay and Net Pay

Posted 28 July 2012 - 07:11 PM

Warning W8065 ModularPay.c 83: Call to function 'Id' with no prototype in function main

Try adding void in the parentheses of the prototypes.

23	   void Id(void);




Warning W8070 ModularPay.c 69: Function should return a value in function Calc_GrossPay

You could return the value GrossPay like so

69	   return GrossPay;
70	   }




You have employee_id as an double here :

13	   double employee_id;




... but use it with %d in the scanf and printf format strings, which denotes an integer.

30	      void Id()
31	   {
32	   /*  Get Employees Id */
33	      printf("Enter your Employee Identification \n");
34	      scanf("%d",&employee_id);
35	      printf(" Your Employee Identification is: %d \n", employee_id);
36	               
37	   }



What data type should employee_id be?

In Rate() you previously used %lf which is correct for a double (long float). Why did you change it?

previous code :
38	   void Rate()
39	   {
40	   /* Get Employees Hourly Rate */
41	      printf("Enter your hourly Rate\n");
42	      scanf("%lf",&HourlyRate);
43	      printf("Your Hourly Rate is: %lf \n", HourlyRate);
44	               
45	   }




Printf Format Strings
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1