Solved

c# piecework program

Posted on 2003-10-27
4
841 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Batch file output 20 76
userCompare  challenge 3 61
powerN  challenge 3 46
listing all functions in JavaScript 19 96
This is about my first experience with programming Arduino.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now