# CAN YOU HELP ME PLEASE I NEED IT TOM..

Page 1 of 1

## 13 Replies - 788 Views - Last Post: 09 February 2013 - 01:51 AMRate Topic: 1 Votes //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=311661&amp;s=af362e72b290711fc2971e93ff3a8783&md5check=' + ipb.vars['secure_hash'], cur_rating: 1, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 swiss21

Reputation: 0
• Posts: 15
• Joined: 09-February 13

# CAN YOU HELP ME PLEASE I NEED IT TOM..

Posted 09 February 2013 - 12:31 AM

#include <stdio.h>
#include <float.h>

float grosssalarycalc(float value1,float value2){
float gsalary;
gsalary=value1+value2;
return (gsalary);
}

float ovtmpayoutcalc(float value1){
float ovtmpayout;
ovtmpayout=25*value1;
return (ovtmpayout);
}

float netpayoutcalc(float value1){
float netsalary;
netsalary=value1-(value1*0.20);
return (netsalary);
}

int main() {
char name[32];
float ovtmpayout0,gross,net,ovtmhrs,salary;

printf("Payroll Calculation Program\n");
scanf("%s", name);
scanf("%f", &salary);
printf("Employee, how many overtime hours have you worked?\n");
scanf("%f",&ovtmhrs);
printf("---------------------\n\n");

ovtmpayout0=ovtmpayoutcalc(ovtmhrs);
gross=grosssalarycalc(salary,ovtmpayout0);
net=netpayoutcalc(gross);

printf("October 16th, 2012\n");
printf("Employee Name: %s\n", name);
printf("Overtime Hours Worked: %.0f\n", ovtmhrs);
printf("Gross Payout: %.2f\n", gross);
printf("Net Salary: %.2f\n", net);

system ("pause");
return 0;
}

Is This A Good Question/Topic? 0

## Replies To: CAN YOU HELP ME PLEASE I NEED IT TOM..

### #2 Martyr2

• Programming Theoretician

Reputation: 5186
• Posts: 13,914
• Joined: 18-April 07

## Re: CAN YOU HELP ME PLEASE I NEED IT TOM..

Posted 09 February 2013 - 12:37 AM

Well you certainly aren't doing yourself any favors by posting without code tags, without stating a question and without giving us an idea of what isn't working.

You would think you would want to provide your saviors with that sort of information don't you think?

This post has been edited by Martyr2: 09 February 2013 - 12:38 AM

### #3 swiss21

Reputation: 0
• Posts: 15
• Joined: 09-February 13

## Re: CAN YOU HELP ME PLEASE I NEED IT TOM..

Posted 09 February 2013 - 12:39 AM

#include <stdio.h>
#include <float.h>

float grosssalarycalc(float value1,float value2){
float gsalary;
gsalary=value1+value2;
return (gsalary);
}

float ovtmpayoutcalc(float value1){
float ovtmpayout;
ovtmpayout=25*value1;
return (ovtmpayout);
}

float netpayoutcalc(float value1){
float netsalary;
netsalary=value1-(value1*0.20);
return (netsalary);
}

int main() {
char name[32];
float ovtmpayout0,gross,net,ovtmhrs,salary;

printf("Payroll Calculation Program\n");
scanf("%s", name);
scanf("%f", &salary);
printf("Employee, how many overtime hours have you worked?\n");
scanf("%f",&ovtmhrs);
printf("---------------------\n\n");

ovtmpayout0=ovtmpayoutcalc(ovtmhrs);
gross=grosssalarycalc(salary,ovtmpayout0);
net=netpayoutcalc(gross);

printf("October 16th, 2012\n");
printf("Employee Name: %s\n", name);
printf("Overtime Hours Worked: %.0f\n", ovtmhrs);
printf("Gross Payout: %.2f\n", gross);
printf("Net Salary: %.2f\n", net);

system ("pause");
return 0;
}

im so sorry im just a beginner here,but this is my problem,after enterring daily hours friday the program will stop.

### #4 swiss21

Reputation: 0
• Posts: 15
• Joined: 09-February 13

## Re: CAN YOU HELP ME PLEASE I NEED IT TOM..

Posted 09 February 2013 - 12:45 AM

#include <stdio.h>
#include <float.h>

float grosssalarycalc(float value1,float value2){
float gsalary;
gsalary=value1+value2;
return (gsalary);
}

float ovtmpayoutcalc(float value1){
float ovtmpayout;
ovtmpayout=25*value1;
return (ovtmpayout);
}

float netpayoutcalc(float value1){
float netsalary;
netsalary=value1-(value1*0.20);
return (netsalary);
}

int main() {
char name[32];
float ovtmpayout0,gross,net,ovtmhrs,salary;

printf("Payroll Calculation Program\n");
scanf("%s", name);
scanf("%f", &salary);
printf("Employee, how many overtime hours have you worked?\n");
scanf("%f",&ovtmhrs);
printf("---------------------\n\n");

ovtmpayout0=ovtmpayoutcalc(ovtmhrs);
gross=grosssalarycalc(salary,ovtmpayout0);
net=netpayoutcalc(gross);

printf("October 16th, 2012\n");
printf("Employee Name: %s\n", name);
printf("Overtime Hours Worked: %.0f\n", ovtmhrs);
printf("Gross Payout: %.2f\n", gross);
printf("Net Salary: %.2f\n", net);

system ("pause");
return 0;
}

### #5 Martyr2

• Programming Theoretician

Reputation: 5186
• Posts: 13,914
• Joined: 18-April 07

## Re: CAN YOU HELP ME PLEASE I NEED IT TOM..

Posted 09 February 2013 - 12:48 AM

You mean you want to enter in multiple days? I see no where in your code you refer to a "Friday" or any other days other than October 16th.

Tell us how you want the program to work. So far everything in your program works just as you wrote it and your calculations are fine. Step us through the process you need to do for the assignment.

Thanks.

### #6 swiss21

Reputation: 0
• Posts: 15
• Joined: 09-February 13

## Re: CAN YOU HELP ME PLEASE I NEED IT TOM..

Posted 09 February 2013 - 12:52 AM

oh im sorry this is not the code,i will post it again

```#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
int main()
{
printf("\t//*****************Removed******************\\ \n\n");
printf("\t------------Removed---------------\n\n");
printf("\t^^^/>/>^^/>^/>^^/>^Computer Science IA-Pay Roll System^^^/>/>^^/>^/>^^/>^/>\n\n");
int hours;
int mo, tu, we, th, fr;
int salary_deduct=0;salary_deduct>20;salary_deduct++;
int normal_pay;
int over_time; /*Overtime pay increases the pay rate from \$20 to \$25*/
char fname[50];
char lname[20];
int bonus=0;bonus>1;bonus++; /* Adds \$3000 to workers going over 70 hours*/
int education_tax;
int NIS_tax;
int NHT_tax;
int medical_dental;
int netpay;
int netpay1;
int netpay2;
int netpay3;
{
printf("Enter the employee's First Name:\n");
scanf("%s",&fname[50]);
printf("Enter the employee's Last Name:\n");
scanf("%s",&lname[20]);
printf("Enter daily hours for Monday:\n");
scanf("%d",&mo);
printf("Enter daily hours for Tuesday:\n");
scanf("%d",&tu);
printf("Enter daily hours for Wednesday:\n");
scanf("%d",&we);
printf("Enter daily hours for Thursday:\n");
scanf("%d",&th);
printf("Enter daily hours for Friday:\n");
scanf("%d",&fr);

hours=mo+tu+we+th+fr;
printf("\nThe weekly hours are:%d\n",hours);
normal_pay=hours*20;
over_time=(hours-60)*40+normal_pay;
bonus=over_time+3000;
salary_deduct=hours*20-hours*10;
}

{
if(hours<=40)
printf("\nThe employee is slacking and salary will be deducted!\nThe gross pay is:\$%d dollars\n",salary_deduct);
else if(hours<=60)
printf("\nThe employee will get normal pay\nThe gross pay is:\$%d dollars\n",normal_pay);
else if(hours<=70)
printf("\nThe employee is working over time and will get overtime pay\nThe gross pay is:\$%d dollars\n",over_time);
else
printf("\nTHE EMPLOYEE IS WORKING EXTREMELY HARD AND WILL GET A BONUS ON HIS PAY!\nThe gross pay is:\$%d\n",bonus);
}
{
education_tax=hours*20*.06;
printf("Education tax of %6:\$-%d\n",education_tax);
NHT_tax=hours*20*.1;
printf("NHT tax of %10:\$-%d\n",NHT_tax);
NIS_tax=hours*20*.05;
printf("NIS tax of %5:\$-%d\n",NIS_tax);
medical_dental=hours*20*.05;
printf("Medical/dental of %5:\$-%d\n",medical_dental);
}
{
netpay=salary_deduct-(NHT_tax+education_tax+NIS_tax+medical_dental);
netpay1=normal_pay-(NHT_tax+education_tax+NIS_tax+medical_dental);
netpay2=over_time-(NHT_tax+education_tax+NIS_tax+medical_dental);
netpay3=bonus-(NHT_tax+education_tax+NIS_tax+medical_dental);
if(hours<=40)
printf("The net pay is:\$%d\n",netpay);
else if(hours<=60)
printf("The net pay is:\$%d\n",netpay1);
else if(hours<=70)
printf("The net pay is:\$%d\n",netpay2);
else
printf("The net pay is:\$%d\n",netpay3);
}
return 0;
}

```

im sorry i dont know how to use the tags

This post has been edited by Martyr2: 09 February 2013 - 12:55 AM
Reason for edit:: Removed personal identifying info and corrected code tags.

### #7 Martyr2

• Programming Theoretician

Reputation: 5186
• Posts: 13,914
• Joined: 18-April 07

## Re: CAN YOU HELP ME PLEASE I NEED IT TOM..

Posted 09 February 2013 - 01:00 AM

In the future you may not want to print your name and school publicly on the Internet. I have removed that info and corrected your code tags. The tags are very easy to use. You click the code button at the top and put your code IN BETWEEN the two tags you see.

### #8 swiss21

Reputation: 0
• Posts: 15
• Joined: 09-February 13

## Re: CAN YOU HELP ME PLEASE I NEED IT TOM..

Posted 09 February 2013 - 01:02 AM

thank you very much savior martyr,and im very thankful to you because of your kindness and willingness to help me,so what's wrong in my code?

### #9 Martyr2

• Programming Theoretician

Reputation: 5186
• Posts: 13,914
• Joined: 18-April 07

## Re: CAN YOU HELP ME PLEASE I NEED IT TOM..

Posted 09 February 2013 - 01:07 AM

How you are entering your names is not correct...

```printf("Enter the employee's First Name:\n");
scanf("%s",&fname[50]);

printf("Enter the employee's Last Name:\n");
scanf("%s",&lname[20]);

```

These are not suppose to go into indexes here, you declared them to be of length 50 and 20 already. Just put the typed values right into the name...

```printf("Enter the employee's First Name:\n");
scanf("%s",&fname);

printf("Enter the employee's Last Name:\n");
scanf("%s",&lname);

```

This will make the program compile. Then you can go and check your calculations to see if they are all correct.

P.S. Make sure that the firstname is not longer than 49 and the lastname is not longer than 19 or else you will have issues. Just a tip.

This post has been edited by Martyr2: 09 February 2013 - 01:13 AM

### #10 swiss21

Reputation: 0
• Posts: 15
• Joined: 09-February 13

## Re: CAN YOU HELP ME PLEASE I NEED IT TOM..

Posted 09 February 2013 - 01:14 AM

Savior martyr my program compile and run but after putting the Enter daily hours for friday the program will just close.

### #11 Martyr2

• Programming Theoretician

Reputation: 5186
• Posts: 13,914
• Joined: 18-April 07

## Re: CAN YOU HELP ME PLEASE I NEED IT TOM..

Posted 09 February 2013 - 01:20 AM

That is how C programs work. It runs your program and closes when it is done. You can prevent this by putting the statement getch(); right before the return 0; statement. Then all you need to do to close the program is to hit a character on your keyboard.

### #12 swiss21

Reputation: 0
• Posts: 15
• Joined: 09-February 13

## Re: CAN YOU HELP ME PLEASE I NEED IT TOM..

Posted 09 February 2013 - 01:24 AM

oh thank you very much SAVIOR MARTYR, now i can proceed to my next program,can you still help me MASTER?

### #13 Martyr2

• Programming Theoretician

Reputation: 5186
• Posts: 13,914
• Joined: 18-April 07

## Re: CAN YOU HELP ME PLEASE I NEED IT TOM..

Posted 09 February 2013 - 01:25 AM

First of all, enough with the whole Savior/Master crap. And no, I am off to bed now. Try the next one on your own.

### #14 snoopy11

• Engineering ● Software

Reputation: 1455
• Posts: 4,704
• Joined: 20-March 10

## Re: CAN YOU HELP ME PLEASE I NEED IT TOM..

Posted 09 February 2013 - 01:51 AM

Martyr2, on 09 February 2013 - 08:25 AM, said:

First of all, enough with the whole Savior/Master crap. And no, I am off to bed now. Try the next one on your own.

I was wondering how long you were going to put up
with the saviour/master thing without being physically sick....

Snoopy.