?
Solved

c# piecework program

Posted on 2003-10-27
4
Medium Priority
?
866 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 60 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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?
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Starting up a Project
Suggested Courses

777 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