1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Akimi4 [234]
4 years ago
12

An employee is paid at a rate of $16.78 per hour for the first 40 hours worked in a week. Any hours over that are paid at the ov

ertime rate of oneand-one-half times that. From the worker’s gross pay, 6% is withheld for Social Security tax, 14% is withheld for federal income tax, 5% is withheld for state income tax, and $10 per week is withheld for union dues. If the worker has three or more dependents, then an additional $35 is withheld to cover the extra cost of health insurance beyond what the employer pays. Write a program that will read in the number of hours worked in a week and the number of dependents as input and will then output the worker’s gross pay, each withholding amount, and the net take-home pay for the week. For a harder version, write your program so that it allows the calculation to be repeated as often as the user wishes. If this is a class exercise, ask your instructor whether you should do this harder version.

Computers and Technology
1 answer:
Ostrovityanka [42]4 years ago
8 0

Answer:

Here is the C++ program:

#include<iostream>  // to use input output functions

using namespace std;  //to access objects cin cout

int main() {  //start of main function

int hrsWorked;  //stores the number of hours worked

   int dependents;  //stores the number of dependents

double grossPay;  //stores the gross pay

char choice;  //store the value for choice of user to continue

do {  //loop that keeps repeating as often as the user wishes

  cout<<"Enter number of hours worked in a week: ";  // prompts user to enter number of weeks

  cin>>hrsWorked;  //reads input value for number of hours worked

  cout<<"Enter number of dependents : "; // prompts user to enter number of dependents

  cin>>dependents;  //reads input value for number of dependents  

      if(hrsWorked>40)  //if hours worked are more than 40

       {grossPay = ((40 * 16.78) + (hrsWorked-40)*(16.78*1.5));  }  //employee is paid at the overtime rate of one and-one-half times

       else  //if hours worked are not more than 40

      { grossPay = (hrsWorked*16.78);}  // employee is paid at a rate of $16.78 per hour        

      double ssTax = 0.06* grossPay ;  //computes 6% Social Security tax withheld from gross pay

      double fIncomeTax = 0.14* grossPay;  //computes 14% federal income tax withheld from gross pay

      double sIncomeTax = 0.05 * grossPay;  //computes 5% state income tax withheld from gross pay      

   cout<<"worker’s pay: "<<grossPay<<endl;  //displays workers pay

   cout<<"worker’s gross pay after withholding amounts:"<<endl;  //displays workers pay including withholding amounts

   cout<<"withhold amount for state income tax is: "<<sIncomeTax<<endl;  //displays grosspay with state income tax withheld

   cout<<"withhold amount for social security tax is: "<<ssTax<<endl;  //displays grosspay with Social Security tax withheld

   cout<<"withhold amount for federal income tax is: "<<fIncomeTax<<endl;  //displays grosspay with federeal income tax withheld

   cout<<"withhold amount  for union dues is: $10 "<<endl;   // $10 per week is withheld for union dues

if(dependents >= 3) {  //if worker has three or more dependents

cout<<"withhold amount of $35 for health insurance "<<endl;

  grossPay = grossPay - 35;  }  //an additional $35 is withheld to cover the extra cost of health insurance beyond what the employer pays  

    cout<<endl;  //prints a new line

    double take_homepay;  //stores the net take-home pay for the week.

    take_homepay = ((grossPay- ssTax- sIncomeTax - fIncomeTax) - 10);  //compute the net t ake-home pay for the week

cout<<"net amount take-home pay for the week is: "<<take_homepay;  //displays the net take-home pay for the week

    cout<<endl;  //prints a new line

cout<<"\nDo you want to continue? (press y to repeat or any key to quit)";  //ask user to repeat the calculation

cin>>choice;  //reads choice from user

cout<<endl;  //prints a new line

}while(choice =='y' || choice =='Y');  }   //loop continues to execute till user wants to repeat calculations and stops when user presses any key other than y or Y

Explanation:

The program works as follows:

Suppose number of working hours is 40 and number of dependents is 2

hrsWorked = 40

dependents = 2

if(hrsWorked>40) this condition evaluates to false because hrsWorked is equal to 40 so else part executes:

grossPay = (hrsWorked*16.78); this becomes:

grossPay = 40 * 16.78

grossPay = 671.2

double ssTax = 0.06* grossPay ;  this statement withholds 6% Social Security tax from gross pay. This becomes:

ssTax = 0.06* 671.2;

ssTax = 40.272

double fIncomeTax = 0.14* grossPay;  this statement withholds 14% federal income tax from gross pay. This becomes:

fIncomeTax = 0.14* 671.2;

fIncomeTax = 93.968

double sIncomeTax = 0.05 * grossPay;  this statement withholds 5% state income tax from gross pay. This becomes:

sIncomeTax = 0.05 * 671.2

sIncomeTax = 33.56

if(dependents >= 3) this condition is false because number of dependents is 2

Next to compute  net take-home pay the program control moves to the statement:

take_homepay = ((grossPay- ssTax- sIncomeTax - fIncomeTax) - 10)

this becomes:

take_homepay = ((671.2 - 40.272 - 33.56 - 93.968) - 10)

Note that the 10 here is the $10 per week which is withheld for union dues.

take_homepay = ((671.2 - 40.272 - 33.56 - 93.968) - 10)

take_homepay = 503.4 - 10

take_homepay = 493.4

The screenshot of the output of this program is attached.

You might be interested in
Discuss the various types of keys available on a computer keyboard.<br>No spam answer needs!❌❌​
olga nikolaevna [1]

Answer:• Alphanumeric keys – all of the letters and numbers on the keyboard. A-Z and 0-9.

• Punctuation keys – All of the keys associated with punctuation such as the comma,

period, semicolon, brackets, parenthesis and so on. Also, all of the mathematical

operators such as the plus sign, minus sign, and equal sign.

• Special keys – All of the other keys on the computer keyboard such as the function

keys, control keys, arrow keys, caps lock key, delete key, etc.

Special keys on a PC Keyboard

• Alt key – Short for Alternate, this key is like a second control key.

• Arrow Keys – Most keyboards have four arrow keys that enable you to move the

cursor (or insertion point) up, down, right, or left. Used in conjunction with the Shift

or Alt keys, the arrow keys can move the cursor more than one position at a time, but

this depends on which program is running.

• Backspace key – Deletes the character just to the left of the cursor (or insertion

point) and moves the cursor to that position.

• Caps Lock Key – A toggle key that, when activated, causes all alphabetic characters

to be uppercase.

• Ctrl key – Short for Control, this key is used in conjunction with other keys to

produce control characters. The meaning of each control character depends on which

program is running.

• Delete Key – Sometimes labeled Del, deletes the character at the current cursor

position, or the selected object, but does not move the cursor. For graphics-based

applications, the Delete key deleted the character to the right of the insertion point.

• Enter Key – Used to enter commands or to move the cursor to the beginning of the

next line. Sometimes labeled Return instead of Enter.

• Esc Key – Short for Escape, this key is used to send special codes to devices and to

exit (or escape) from programs and tasks.

• Function Keys – Special keys labeled F1 to F12. These keys have different meaning

depending on which program is running.

Explanation: use quillbot or wordtune to change the words

3 0
2 years ago
Natural language generation is focused on?
Mila [183]

While natural language understanding focuses on computer reading comprehension, natural language generation enables computers to write. NLG is the process of producing a human language text response based on some data input. This text can also be converted into a speech format through text-to-speech services.

<em>-</em><em> </em><em>BRAINLIEST</em><em> answerer</em>

6 0
3 years ago
Why is it essential for every person living in the 21st century to have a computer​
Zolol [24]

Answer: because computers are our main source of communicating and where we find a wide range of information to help us

Explanation:

4 0
3 years ago
Flexibility and cost reduction are advantages generally associated with ? networks.
ahrayia [7]

Answer:

Wireless networks

Explanation:

Wireless networks provide more configuration flexibility and are less expensive. Companies that add employees will greatly benefit from the flexibility of wireless connections. Workstations can be moved with ease without the effort and cost required to run wires and cables. It is the best for network expansion since companies can add users quickly and grow their networks cost-effectively.

7 0
4 years ago
What is the base of a number system?
Vinvika [58]

A number base is the number of digits or combination of digits that a system of counting uses to represent number. The most commonly used number system is the decimal system, commonly known as base10.

6 0
3 years ago
Other questions:
  • Which option describes wearable technology?
    5·2 answers
  • Sometimes, fourth-generation languages (4GLs) are called procedural languages
    9·1 answer
  • Se citește un număr natural n cu cel mult 16 cifre. Fie q numărul de cifre ale numărului n. Prin eliminarea unei singure cifre d
    5·1 answer
  • 4-One possible performance multiplication enhancement is to do a shift and add instead of an actual multiplication. Since 9 * 6,
    12·1 answer
  • What is the key function of a sales team?
    13·1 answer
  • Chegg A full bootstrap program Select one: a. may be infected by viruses. b. is stored in ROM to ensure to avoid any infection f
    13·1 answer
  • Administrators who are wary of using the same tools that attackers use should remember that a tool that can help close an open o
    6·1 answer
  • This is really dumb but can someone help me find these memes? I can’t remember what they’re called but I remember how they went
    14·2 answers
  • Without net neutrality, which of these situations might occur? (Select all that apply.) a cable company might charge different b
    5·1 answer
  • The electors in each state shall have the qualifications requisite for electors of the most numerous branch of the state legisla
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!