473,473 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

net salary calc

2 New Member
guys I have just started to learn c programing and i have some small assign ment to do . i cant go through , Please help, That is to calulate net salary after
tax.1.gross salay = 78000
2.social security 7.5% for the first 58000
3.fderal tax 3000 and 28% above 3000
4 state tax is 10 %
thank you

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define GROSS_SALARY    78000
  5. #define FEDERAL_TAX_BP  30000
  6. #define FEDERAL_TAX_RATE        .28
  7. #define FEDERAL_TAX_FR          3000
  8. #define SOCIAL_SECURITY_BP      58000
  9. #define SOCIAL_SECURITY_RATE    .075
  10. #define STATE_TAX_RATE          .10
  11.  
  12.  double FEDERAL_TAX;
  13.  double SOCIAL_SECURITY;
  14.  double STATE_TAX;
  15.  double TOTAL_TAX;
  16.  double NET_SALARY;
  17.  double FEDERAL_TAX_TAXABLE;
  18.  double FEDERL_TAX_FR;
  19.  double FEDERAL_TAX_BP;
  20.  double FEDERAL_TAX_RATE;
  21.  
  22. int main()
  23. {
  24.  
  25.  
  26.     FEDERAL_TAX_TAXABLE = GROSS_SALARY - FEDERAL_TAX_ BP;
  27.     FEDERAL_TAX = FEDERL_TAX_FR + FEDERAL_TAX_TAXABLE * FEDERAL_TAX_RATE;
  28.     SOCIAL_SECURITY = SOCIAL_SECURITY_BP * SOCIAL_SECURITY_RATE;
  29.     STATE_TAX = GROSS_SALARY * STATE_TAX_RATE;
  30.     TOTAL_TAX = FEDERAL_TAX + SOCIAL_SECURITY + STATE_TAX;
  31.     NET_SALARY = GROSS_SALARY - TOTAL_TAX;
  32.  
  33.     printf("Gross Salary: t\t\%7.2f\n",GROSS_SALARY);
  34.     printf("Federal Tax Break Point: %7.2f\n",FEDERAL_TAX_BP);
  35.     printf("Federal Tax Flat Rate: %7.2f\n",FEDERAL_TAX_FR);
  36.     printf("Ferderal Tax at rate of 7.5: %7.2\n",FEDRAL_TAX);
  37.     printf("Social security Break Point: %7.2\n", SOCIAL_SECURITY_BP);
  38.     printf("Social Security at rate of : %7.2f\n",SOCIAL_SECURITY);
  39.     printf("State Tax at 10% rate: %7.2\n",STATE_TAX);
  40.     printf("Total Tax :\t\t\t\t %7.2\n",TOTAL_TAX);
  41.     printf("Net Salary:   \t\t\t %7.2\n",NET_SALARY);
  42.     printf(" Please Touch Any Key When Done \n");
  43.     getchar();
  44.     return EXIT_SUCCESS;
  45. }
Sep 7 '08 #1
8 2374
donbock
2,426 Recognized Expert Top Contributor
So what happens when you run your program; and how does that differ from your expectations?
Cheers,
donbock
Sep 7 '08 #2
Parul Bagadia
188 New Member
In the first line of your main function; you have used space in between _ and BP. So it must be giving u an error named; undeclared variable. Because when you have defined it you have not used any space in between.
And when you use getchar(); it inputs any key u press and echos it ; where as it is not the case with getch(); So if u dont want that charachter and want user only top enter a key; you should use getch(); and not getchar();
What purpose does 7.2f serves?
Sep 7 '08 #3
Laharl
849 Recognized Expert Contributor
Also, please use CODE /CODE tags when posting code to make it easier to read.
Sep 7 '08 #4
sicarie
4,677 Recognized Expert Moderator Specialist
And when you use getchar(); it inputs any key u press and echos it ; where as it is not the case with getch(); So if u dont want that charachter and want user only top enter a key; you should use getch(); and not getchar();
I'd strongly recommend against using getch() ever. It requires a non-standard library to implement, which can affect portability and versioning of your program.

If you can duplicate the functionality without using getch(), it is a good idea to do so.
Sep 7 '08 #5
Parul Bagadia
188 New Member
I'd strongly recommend against using getch() ever. It requires a non-standard library to implement, which can affect portability and versioning of your program.

If you can duplicate the functionality without using getch(), it is a good idea to do so.
I didnt know this.
Can you explain a bit more about how it affects the portability and versioning of our program; because i use it many times; without knowing the actual scenario.
Sep 7 '08 #6
sicarie
4,677 Recognized Expert Moderator Specialist
I didnt know this.
Can you explain a bit more about how it affects the portability and versioning of our program; because i use it many times; without knowing the actual scenario.
Sure. Getch() is a member of conio.h (Wikipedia link) - which is a library whose implementation varies by version and compiler. Because of a lack of standardization, functions are not guaranteed to behave the same way, and

functions declared by conio.h vary significantly from compiler to compiler
It is because of that variance that executables will behave radically different, and sometimes not at all, depending on the version of conio.h that is installed.

::edit:: Versioning shouldn't be too much of an issue as I don't believe conio.h is being supported any more, so you won't need to alter functionality to support new versions, however use of conio.h will require a published set of 'Requirements' so that anyone running your program has a compatible version of that library.
Sep 7 '08 #7
mulugeta01
2 New Member
Itstops With A Error ,not Executed,pls Can Some Have Time To Modify Mine
Thankyou
Sep 8 '08 #8
sicarie
4,677 Recognized Expert Moderator Specialist
Itstops With A Error ,not Executed,pls Can Some Have Time To Modify Mine
Thankyou
Did you read Parul's post? Did you read the error message and check the line that it came from?

What have you tried to fix this error? per our Posting Guidelines we cannot just do your work for you.
Sep 8 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Astra | last post by:
Hi All Wonder if you can help me with the following calc, which I want to create to check whether or not a user has entered a valid credit card expiry date: 1) I have retrieve a value from 2 x...
2
by: Deano | last post by:
OK, I'm working on a solution to the following problem but there are other ways to skin a cat as they say... Here's the table (simplified); ID EmployeeName SalaryAcc 1 Brown ...
5
by: Stu | last post by:
What are .NET programmers making now a days? No one has to answer or give their exact salary, but I think it might be useful for those of us who think they might be underpaid :) I know it varies a...
1
by: sallyk57 | last post by:
Help with following Programs: Write two programs one where the performance rating here shoud be entered as a int where Excellent =1, Good= 2, Poor=3. an employee who is rated excellent will...
1
by: punkybrewster | last post by:
Basically my task is to write a program that computes and displays the weekly salaries of a company's salespeople based upon information entered by the user and that also displays the total for the...
21
by: mm | last post by:
(Yes, I konw whats an object is...) BTW. I did a translation of a pi callculation programm in C to Python. (Do it by your own... ;-) -------- Calc PI for 800 digs(?). (german: Stellen) ------...
5
by: james121285 | last post by:
This is to calculate an employees tax and pension. The salary is input from the keyboard. The NI contribution is calculated as 6% of the gross salary. The pension contribution is calculated as 2%...
8
by: hmmtn | last post by:
I would appreciate any help on this one. Assignment is as follows: Develop a program that will determine the gross pay for each of several employees. The company pays "straight time" for the first...
4
by: sonia.sardana | last post by:
I know how how to retrive the largest & second largest salary. tell me how to retrive the 3,4,5,...............Largest salary. Create table empl(empid int, empname varchar,salary int) insert...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.