Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 885
  • Last Modified:

c# piecework program

Does anyone know how to write a program that does this: piecework workers are paid by the piece. workers who produce a greater quantity of output are often paid at a higher rate. The program will accept the name, the number of pieces produced and then displays the total number of pieces, The count of employees entered,the total net pay, and the average pay per person. In the calculations, subtract tax 10% and $20.00 from the grosspay. You will add a basepay of $50 to every workers income whether they produced any piece or not
pieces completed:
0-100
101-150
151-200
200 or more
prices paid per piece for all pieces
0-100 .65
101-150 .70
151-200 .75
200 or more .85

Note: Do not use text box to accept input. Use console window
0
uchetex
Asked:
uchetex
  • 2
1 Solution
 
Arthur_WoodCommented:
sounds like a homework assignment to me.  If it is, experts at EE are NOT allowed to do the work for you.  We will HELP you figure out what the code should be, for yourself.  If you have tried something already, then post the code that you have, and someone here will try to assist you.

AW
0
 
uchetexAuthor Commented:
This is what the code looks like any help

using System;

class Testing
{
      static void Main(string [] args)
      {
      
      string Name;
      Console.WriteLine("Welcome") ;

      do
      {

            

            Piecework Employee= new Employee ();
            
            Console.WriteLine("This is Employee number {0}", Piecework.EmployeeCount);


            Console.Write("Enter the name of the Employee: ");
            Employee.Name= Console.ReadLine();

            Console.Write("Enter number of pieces produced: ");
            Employee.Quantity= int.Parse(Console.ReadLine());

            
            

            Console.WriteLine ("The Netpay is:{0} Grosspay is: {1} ", Employee.Netpay, Employee.Grosspay);

      } while(!Done());

      
      Console.WriteLine ("Bye");
      
      }

      static bool Done ()
      {
      Console.Write("\nAgain? ");

      return (Console.ReadLine () .ToUpper ( ).Substring(0,1) .ToCharArray
      () [0] == 'Y') ? false:true;


      }
}

      

       public class Piecework
      {
      
      
      

      static public int_EmployeeCount;
      static int_Totalpieces;

      //Employee Accumulator
      
      public Piecework ()
      {
            Console.WriteLine("Creating another instance");
            _EmployeeCount++;

      }

            

            



      //Calculation
      


      public float Grosspay
      {
            get
            {
                  
                  
            float_Quantity;
            float_Payrate;
            float _Basepay;

            Basepay=50;
      
      _Grosspay=(Quantity*_Payrate)+(_Basepay);
      
            return _Grosspay;
            
            }

            set
             {
             if (Quantity==0)
            _Grosspay=50;
      else
            _Grosspay=value;
            }
}




public float Netpay
{
      get
      {
            
       float _Tax=0.1F;
       float _Health=20;
      float _Total;      

      _Total= _Grosspay - _Tax- _Health;
      
      if (Quantity >=201)
      _Payrate= 0.85;

      else
      if (Quantity >= 151)
      _Payrate=0.75;

      else
      if (Quantity >=101)
      _Payrate=0.70;

      else
      if (Quantity >=0)
      _Payrate=0.65;

      return _Total;
      }

      set
      {
      _Total=value;
      }

}

      
      public static int EmployeeCount
      {
            get
            {
                  return_EmployeeCount;
            }
      }



      
      
}

      





            
0
 
Arthur_WoodCommented:
this code cannot possibly compile, as you have not denied, in your Employee class, Properties to accept these values:

         Console.Write("Enter the name of the Employee: ");
          Employee.Name= Console.ReadLine();

          Console.Write("Enter number of pieces produced: ");
          Employee.Quantity= int.Parse(Console.ReadLine());

where is the Name property defined?  Where is the Quantity property defined, in the code for your Employee class?

then, this code:

     float _Tax=0.1F;
      float _Health=20;
     float _Total;    

     _Total= _Grosspay - _Tax- _Health;
     
     if (Quantity >=201)
     _Payrate= 0.85;

     else
     if (Quantity >= 151)
     _Payrate=0.75;

     else
     if (Quantity >=101)
     _Payrate=0.70;

     else
     if (Quantity >=0)
     _Payrate=0.65;

     return _Total;
     }

     set
     {
     _Total=value;
 computes a value for _PayRAte that is never used, as you have already computed

_Total= _Grosspay - _Tax- _Health;


BEFORE _PayRate is determined.

0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now