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
Having Trouble with this C++ assignment THe places that are marked // TODO is where code...
Having Trouble with this C++ assignment THe places that are marked // TODO is where code should be filled in at Header (myQueue.h) #ifndef _MYQUEUE_H_ #define _MYQUEUE_H_ using namespace std; template class myQueue { public:    myQueue(int maxSz);    ~myQueue();    void enqueue(T item);    T dequeue(); int currentSize(); bool isEmpty(); bool isFull(); private:    T *contents; /*Dynamic initiate (C++ keyword new) the holder array*/    int front,rear; /*Index in the array of the front and rear element*/    int...
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...
why would it be more difficult to replace an ankle than a knee, or hip, or...
why would it be more difficult to replace an ankle than a knee, or hip, or even an elbow or shoulder?
Below is my code, Replace the 2 static_cast codes to a simpler C++ code. I would...
Below is my code, Replace the 2 static_cast codes to a simpler C++ code. I would like to find another way to compile the program without using static_cast in my code. Thank you #include <iostream> #include <iomanip> using namespace std; class Population { private: int population, birth, death; public: Population() { population = 2; birth = 0; death = 0; } Population(int x, int y, int z) { if (x < 2) population = 0; else population = x; if...
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!
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT