Answer to Question #255267 in C# for aj jarikpe

Question #255267
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

question is to insert the code to enter and validate ratePay and taxPay


1
Expert's answer
2021-10-22T16:44:00-0400
using System;
using System.Collections.Generic;


namespace Lab6
{


    class Program
    {


        static void Main(string[] args)
        {
            // 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());
            } 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 (between 0 and 1) => ");
                taxRate = Convert.ToDouble(Console.ReadLine());
            } while (taxRate < 0 || taxRate > 1);
        }


    }
}

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