Solved

c# piecework program

Posted on 2003-10-27
4
850 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
This is about my first experience with programming Arduino.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

778 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