Click here to Skip to main content
15,892,005 members
Home / Discussions / C#
   

C#

 
AnswerRe: C#.net date Conversion Problem Pin
Harini N K27-Feb-07 20:00
Harini N K27-Feb-07 20:00 
AnswerRe: C#.net date Conversion Problem Pin
V.27-Feb-07 20:41
professionalV.27-Feb-07 20:41 
AnswerRe: C#.net date Conversion Problem [modified] Pin
IamMohan27-Feb-07 20:50
IamMohan27-Feb-07 20:50 
AnswerRe: C#.net date Conversion Problem Pin
Rhys Gravell27-Feb-07 20:52
professionalRhys Gravell27-Feb-07 20:52 
Question.NET Remoting Chat Pin
Zuhair Rizvi27-Feb-07 19:46
Zuhair Rizvi27-Feb-07 19:46 
QuestionRegarding Online Forms Pin
ravindra250627-Feb-07 19:44
ravindra250627-Feb-07 19:44 
AnswerRe: Regarding Online Forms Pin
Sandeep Akhare27-Feb-07 21:12
Sandeep Akhare27-Feb-07 21:12 
QuestionHelp! I've fallen and can't get up. Pin
JMOdom27-Feb-07 19:14
JMOdom27-Feb-07 19:14 
Sigh | :sigh: Cry | :(( I have been trying to learn C# in a classroom situation. I was given a problem that is supposed to be an OOP program.(I don't know enough to be sure.) The problem says that I'm to get an employee's name and the weekly sales amount. From that I need to figure out the gross pay, net pay, taxes, social security deduction and the retirement contribution. The only input is whats listed above. The other figures are based on constants. I would appreciate any help in steering me in the right direction. Supposedly the code I've written will work, I've based it on what is in the textbook.

My CLASS I've called Deductions. I've listed it below.

using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
namespace Exercise_9_Chapter_4<br />
{<br />
    public class Deduction<br />
    {<br />
        public string name;<br />
        public double weeklySales;<br />
        public double fedTax;<br />
        public double socSec;<br />
        public double retireAcct;<br />
        public double grossPay;<br />
        public double netPay;<br />
        public double weeklySalesAmount;<br />
<br />
        const double GROSS_WEEKLY_PAY = .07;<br />
        const double FEDERAL_TAX = .18;<br />
        const double SOCIAL_SECURITY = .06;<br />
        const double RETIRE_ACCT = .10;<br />
<br />
        //CONSTRUCTORS:<br />
        // default<br />
        public Deduction()<br />
        {<br />
        }<br />
  <br />
         public Deduction(string empName, double weeklySales)<br />
        {<br />
            name = empName;<br />
            weeklySalesAmount = weeklySales;<br />
        }<br />
<br />
        //MUTATORS:<br />
        public double SetGrossPay(double weeklySales)<br />
        {<br />
            grossPay = weeklySales * GROSS_WEEKLY_PAY;<br />
            return grossPay;<br />
        }<br />
<br />
        public void SetFedTax(double grossPay)<br />
        {<br />
            fedTax = grossPay * FEDERAL_TAX;<br />
        }<br />
<br />
        public void SetSocSec(double grossPay)<br />
        {<br />
            socSec = grossPay * SOCIAL_SECURITY;<br />
        }<br />
<br />
        public void SetRetireAcct(double grossPay)<br />
        {<br />
            retireAcct = grossPay * RETIRE_ACCT;<br />
        }<br />
<br />
        public void SetNetPay()<br />
        {<br />
            netPay = grossPay - (fedTax + socSec + retireAcct);<br />
        }<br />
<br />
        //PROPERTIES:<br />
        public double NetPay<br />
        {<br />
            get<br />
            {<br />
                return netPay;<br />
            }<br />
            set<br />
            {<br />
                netPay = value;<br />
            }<br />
        }<br />
        public double GrossPay<br />
        {<br />
            get<br />
            {<br />
                return grossPay;<br />
            }<br />
            set<br />
            {<br />
                grossPay = value;<br />
            }<br />
        }<br />
<br />
        public double FedTax<br />
        {<br />
            get<br />
            {<br />
                return fedTax;<br />
            }<br />
            set<br />
            {<br />
                fedTax = value;<br />
            }<br />
        }<br />
        public double SocSec<br />
        {<br />
            get<br />
            {<br />
                return socSec;<br />
            }<br />
            set<br />
            {<br />
                socSec = value;<br />
            }<br />
        }<br />
<br />
        public double RetireAcct<br />
        {<br />
            get<br />
            {<br />
                return retireAcct;<br />
            }<br />
            set<br />
            {<br />
                retireAcct = value;<br />
            }<br />
        }<br />
<br />
        //ACCESSORS:<br />
        public string GetName<br />
        {<br />
            get<br />
            {<br />
                return name;<br />
            }<br />
        }<br />
        public double GetNetPay<br />
        {<br />
            get<br />
            {<br />
                return netPay;<br />
            }<br />
        }<br />
        public double GetGrossPay<br />
        {<br />
            get<br />
            {<br />
                return grossPay;<br />
            }<br />
        }<br />
        public double GetFedTax<br />
        {<br />
            get<br />
            {<br />
                return fedTax;<br />
            }<br />
        }<br />
        public double GetSocSec<br />
        {<br />
            get<br />
            {<br />
                return socSec;<br />
            }<br />
        }<br />
        public double GetRetireAcct<br />
        {<br />
            get<br />
            {<br />
                return retireAcct;<br />
            }<br />
        }<br />
       <br />
    }<br />
}



The next set is the program that is supposed to read the above material.

using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
namespace Exercise_9_Chapter_4<br />
{<br />
    class Exercise9Chapter4<br />
    {<br />
        static void Main()<br />
        {<br />
<br />
            string empName = DetermineName();<br />
            double wkSales = DetermineWeeklySales();<br />
<br />
         Deduction employee = new Deduction(empName, wkSales);<br />
<br />
            employee.netPay = GetNetPay();<br />
            employee.grossPay = SetGrossPay();<br />
            employee.fedTax = SetFedTax();<br />
            employee.socSec = SetSocSec();<br />
            employee.retireAcct = SetRetireAcct();<br />
<br />
<br />
            DisplayResults();<br />
        }<br />
<br />
        public static void DisplayResults()<br />
        {<br />
        Console.WriteLine();<br />
        Console.WriteLine("Employee name is: " + employee.Name);<br />
        Console.WriteLine();<br />
        Console.WriteLine("The sales for this week are: {0:C} ", weeklySales);<br />
        Console.WriteLine();<br />
        Console.WriteLine("Your Federal taxes were: {0:C} ", fedTax);<br />
        Console.WriteLine();<br />
        Console.WriteLine("Your Social Security was: {0:C} ", socSec);<br />
        Console.WriteLine();<br />
        Console.WriteLine("Your retirement deduction was: {0:C} ", RetireAcct);<br />
        Console.WriteLine();<br />
        Console.WriteLine("Your net take home pay is: {0:C} ", netPay);<br />
        Console.WriteLine();<br />
        }<br />
        <br />
        public static double DetermineWeeklySales()<br />
        {<br />
<br />
            double weeklySalesAmount;<br />
<br />
            Console.WriteLine("Type in weekly sales amount. ");<br />
            string inputAmount = Console.ReadLine();<br />
            weeklySalesAmount = double.Parse(inputAmount);<br />
            return weeklySalesAmount;<br />
<br />
        }<br />
<br />
        public static string DetermineName()<br />
        {<br />
         string inputValue;<br />
<br />
         Console.WriteLine();<br />
         Console.WriteLine("Type in enployees Name.");<br />
         inputValue = Console.ReadLine();<br />
         return inputValue;<br />
<br />
         }<br />
    }<br />
}


When I try to rebuild it, I'm told that the Get statements in the Deduction employee = new Deduction(empName, wkSales); don't exist in the current context. The section in the DisplayResults tells me also that the names after the sentance also don't exist in the current context.

I thought I had writen this correctly, and that the program half was supposed to be able to read the Class.

Hopefully someone can tell me what it is that I'm doing wrong. Sorry that this has taken so much time. Thanks in advance.Rose | [Rose] Confused | :confused: Unsure | :~
AnswerRe: Help! I've fallen and can't get up. Pin
Harini N K27-Feb-07 19:40
Harini N K27-Feb-07 19:40 
AnswerRe: Help! I've fallen and can't get up. Pin
mike montagne27-Feb-07 19:49
mike montagne27-Feb-07 19:49 
GeneralRe: Help! I've fallen and can't get up. Pin
JMOdom28-Feb-07 10:57
JMOdom28-Feb-07 10:57 
GeneralRe: Help! I've fallen and can't get up. Pin
mike montagne28-Feb-07 12:24
mike montagne28-Feb-07 12:24 
QuestionSocket Problem Pin
Rahul.RK27-Feb-07 18:42
Rahul.RK27-Feb-07 18:42 
Questionclosing form with its parent Pin
Saira Tanwir27-Feb-07 17:54
Saira Tanwir27-Feb-07 17:54 
AnswerRe: closing form with its parent Pin
Shajeel27-Feb-07 18:23
Shajeel27-Feb-07 18:23 
AnswerRe: closing form with its parent Pin
Saira Tanwir27-Feb-07 18:42
Saira Tanwir27-Feb-07 18:42 
GeneralRe: closing form with its parent Pin
Shajeel27-Feb-07 19:20
Shajeel27-Feb-07 19:20 
AnswerRe: closing form with its parent Pin
Saira Tanwir27-Feb-07 19:29
Saira Tanwir27-Feb-07 19:29 
QuestionHow to do XML serialization. Pin
wout de zeeuw27-Feb-07 17:49
wout de zeeuw27-Feb-07 17:49 
QuestionTooltip on disabled controls? Pin
Nilesh K.27-Feb-07 17:18
Nilesh K.27-Feb-07 17:18 
AnswerRe: Tooltip on disabled controls? Pin
Shajeel27-Feb-07 18:40
Shajeel27-Feb-07 18:40 
GeneralRe: Tooltip on disabled controls? Pin
Nilesh K.27-Feb-07 18:50
Nilesh K.27-Feb-07 18:50 
GeneralRe: Tooltip on disabled controls? Pin
Harini N K27-Feb-07 18:56
Harini N K27-Feb-07 18:56 
GeneralRe: Tooltip on disabled controls? Pin
Shajeel27-Feb-07 19:13
Shajeel27-Feb-07 19:13 
GeneralRe: Tooltip on disabled controls? Pin
Nilesh K.27-Feb-07 20:10
Nilesh K.27-Feb-07 20:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.