Solved

c# piecework program

Posted on 2003-10-27
4
853 Views
Last Modified: 2008-02-01
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
Comment
Question by:uchetex
  • 2
4 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 9633330
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
 

Author Comment

by:uchetex
ID: 9639633
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
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 30 total points
ID: 9641464
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
topping1 challenge 7 112
Beginner to Unreal Engine 4 5 94
Help Required 3 108
Why is initMap returning "not a function" error. 3 28
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question