Question

In: Computer Science

Replace the lines marked with // *** with the appropriate C# code (may require more than...

Replace the lines marked with // *** with the appropriate C# code (may require more than one line of code to complete the missing parts).



// Program Description: This program uses two user defined methods to compute
//    the gross pay and net pay for an employee after entering the employee’s
//    last name, hours worked, hourly rate, and percentage of tax.

using System;
public static class Lab6
{
   public static void Main()
   {
      // declare variables
      int hrsWrked;
      double ratePay, taxRate, grossPay, netPay=0;
      string lastName;

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

     // enter (and validate) the number of hours worked (positive number)
     do
     {
        Console.Write("Enter the number of hours worked (> 0) => ");
        hrsWrked = Convert.ToInt32(Console.ReadLine());
     } while (hrsWrked < 0);

     // enter (and validate) the hourly rate of pay (positive number)
     // *** Insert the code to enter and validate the ratePay

     // enter (and validate) the percentage of tax (between 0 and 1)
     // *** Insert the code to enter and validate taxRate

     // Call a method to calculate the gross pay (call by value)
     grossPay = CalculateGross(hrsWrked, ratePay);

     // Invoke a method to calculate the net pay (call by reference)
     CalculateNet(grossPay, taxRate , ref netPay);

     // print out the results
     Console.WriteLine("{0} worked {1} hours at {2:C} per hour", lastName,
                       hrsWrked, ratePay);
     // *** Insert the code to print out the Gross Pay and Net Pay
     Console.ReadLine();
  }

  // Method: CalculateGross
  // Parameters
  //      hours: integer storing the number of hours of work
  //      rate: double storing the hourly rate
  // Returns: double storing the computed gross pay
  public static double CalculateGross(int hours, double rate)
  {
     // *** Insert the contents of the CalculateGross Method
  }

  // Method: CalculateNet
  // Parameters
  //      grossP: double storing the grossPay
  //      tax: double storing tax percentage to be removed from gross pay
  //      netP: call by reference double storing the computed net pay
  // Returns: void
  public static void CalculateNet(double grossP, double tax, ref double netP)
  {
     // *** Insert the details of the CalculateNet Method
  }
}

Solutions

Expert Solution

Application name :Lab6App

Language used :C#

Type of Application :Console application

using System;

public static class Lab6
{
public static void Main()
{
// declare variables
int hrsWrked;
double ratePay, taxRate, grossPay, netPay = 0;
string lastName;

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

// enter (and validate) the number of hours worked (positive number)
do
{
Console.Write("Enter the number of hours worked (> 0) => ");
hrsWrked = Convert.ToInt32(Console.ReadLine());
} while (hrsWrked < 0);

// enter (and validate) the hourly rate of pay (positive number)
// *** Insert the code to enter and validate the ratePay
do
{
Console.Write("Enter the hourly rate of pay (> 0) => ");
ratePay = Convert.ToDouble(Console.ReadLine());//reading ratePay
} while (ratePay < 0);

// enter (and validate) the percentage of tax (between 0 and 1)
// *** Insert the code to enter and validate taxRate
do
{
Console.Write("Enter the percentage of tax (> 0 and <1) => ");
taxRate = Convert.ToDouble(Console.ReadLine());//reading taxRate
} while (taxRate< 0 || taxRate>1);

// Call a method to calculate the gross pay (call by value)
grossPay = CalculateGross(hrsWrked, ratePay);

// Invoke a method to calculate the net pay (call by reference)
CalculateNet(grossPay, taxRate, ref netPay);

// print out the results
Console.WriteLine("{0} worked {1} hours at {2:C} per hour", lastName,
hrsWrked, ratePay);
// *** Insert the code to print out the Gross Pay and Net Pay
Console.WriteLine("Gross Pay :{0} and Net Pay : {1}",grossPay,netPay);
Console.ReadLine();
}

// Method: CalculateGross
// Parameters
// hours: integer storing the number of hours of work
// rate: double storing the hourly rate
// Returns: double storing the computed gross pay
public static double CalculateGross(int hours, double rate)
{
// *** Insert the contents of the CalculateGross Method
return hours * rate;//return gross pay by multiplying hours into rate
}

// Method: CalculateNet
// Parameters
// grossP: double storing the grossPay
// tax: double storing tax percentage to be removed from gross pay
// netP: call by reference double storing the computed net pay
// Returns: void
public static void CalculateNet(double grossP, double tax, ref double netP)
{
// *** Insert the details of the CalculateNet Method
netP = grossP - grossP*tax;
}
}

============================================

Output :


Related Solutions

Match the following characteristics with the appropriate costing method: (an option may be used more than...
Match the following characteristics with the appropriate costing method: (an option may be used more than one time): the options are absorption, cost object, variable, differential cost, manufacturing cost. Prompt 1 Fixed manufacturing is treated as a period cost Prompt 2 Easier to predict profit since it is a function of sales Prompt 3 Also known as the full costing method Prompt 4 Required by GAAP Prompt 5 Also know as the direct costing method
Use Racket ;The following two lines are required to test the code. (require rackunit) (require rackunit/text-ui)...
Use Racket ;The following two lines are required to test the code. (require rackunit) (require rackunit/text-ui) Important Rules: 1.) You may not use loop constructs like while/for/sum. If used, your answer will get a zero. 2.) If the instructions state something must be recursive, you will recieve a zero if it is not recursive. Recursive helper functions are allowed (the main function not being recursive). 3.) You may not use the set! command. If used, your answer will get a...
What is the difference between Macroeconomics and Microeconomics? (no more than two lines)
What is the difference between Macroeconomics and Microeconomics? (no more than two lines)
Why is ANOVA more appropriate than multiple t-tests when comparing more than two groups?
Why is ANOVA more appropriate than multiple t-tests when comparing more than two groups?
Discuss why an organization may decide to target more than one market segment. If more than...
Discuss why an organization may decide to target more than one market segment. If more than one segment is targeted, what challenges do you think may exist?   
Please watch the video and comment in no more than 5 lines as to why organizational...
Please watch the video and comment in no more than 5 lines as to why organizational change is so difficult for organizations https://youtu.be/QWORFliXxn0
The line spectrum of helium has many more lines in it than the line spectrum of...
The line spectrum of helium has many more lines in it than the line spectrum of hydrogen. Draw orbital energy diagrams for both H and He, showing all orbitals up through n = 3. Use these diagrams to explain why helium’s line spectrum is so much more complex. They should differ in more than just the number of electrons!
2. There may be only one or there may be more than one correct response to...
2. There may be only one or there may be more than one correct response to this question. You need only mark any one of the possible correct responses to be marked correct. A - Touch the top of the electroscope with your finger B - Remove your finger from the top of the electroscope C - Touch the top of the electroscope with a glass rod that was just previously rubbed by silk D - Touch the top of...
Python 3 Fix the code so if the user enter the same bar code more than...
Python 3 Fix the code so if the user enter the same bar code more than three times, it shows a warning message indicating that the product was already tested 3 times and it reached the limits Code: import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox from datetime import datetime window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1, weight=1) window.grid_rowconfigure(1, weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20,...
5) In no more than five (5) lines of typed text below this question describe the...
5) In no more than five (5) lines of typed text below this question describe the role of “marginal utility per dollar” in decisions whether to purchase goods and services.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT