Answer to Question #241852 in C# for Anino

Question #241852

Return Lines 33-34 to the form:

Console.WriteLine("Employee {0} {1}, (ID: {2}) earned {3:C}",

firstName, lastName, idNum, grossPay);


Assume employees have their wages reduced by 20% to reflect the effects of taxes:


Modify the variable declarations in Line 6 to add netPay:  public static void Main()

  {

    int idNum;

    double payRate, hours, grossPay;

    string firstName, lastName;


Add a new line of code into the program to compute netPay which is grossPay multiplied by 0.8 (80%).

Math Lesson Reminder: The 0.8 multiplier is 1.0 - 0.20. If 20% of the employee's salary goes to tax, 80% of their salary (or 100% - 20%) is what they get to keep.

Modify Lines 33-34 to print out the value of netPay as well as grossPay.


1
Expert's answer
2021-09-25T03:03:23-0400
using System;
using System.Collections.Generic;


namespace App{    
    class Program{
        static void Main(string[] args){
            int idNum;
            double payRate, hours, grossPay, netPay;
            string firstName, lastName;


            // prompt the user to enter employee's first name
            Console.Write("Enter employee's first name => ");
            firstName = Console.ReadLine();


            // prompt the user to enter employee's last name
            Console.Write("Enter employee's last name => ");
            lastName = Console.ReadLine();


            // prompt the user to enter a six digit employee number
            Console.Write("Enter a six digit employee's ID => ");
            idNum = Convert.ToInt32(Console.ReadLine());


            // prompt the user to enter the number of hours employee worked
            Console.Write("Enter the number of hours employee worked => ");
            hours = Convert.ToDouble(Console.ReadLine());


            // prompt the user to enter the employee's hourly pay rate
            Console.Write("Enter employee's hourly pay rate: ");
            payRate = Convert.ToDouble(Console.ReadLine());


            // calculate gross pay
            grossPay = hours * payRate;


            //Add a new line of code into the program to compute netPay which is grossPay multiplied by 0.8 (80%).
            //Math Lesson Reminder: The 0.8 multiplier is 1.0 - 0.20. If 20% of the employee's salary goes to tax, 
            //80% of their salary (or 100% - 20%) is what they get to keep.
            netPay = grossPay * 0.8;


            // output results
            Console.WriteLine("Employee {0} {1}, (ID: {2}) earned {3:C}", firstName, lastName, idNum, netPay);


            Console.ReadLine();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS