Results 1 to 9 of 9

Thread: Visual Net Pay, Gross, & Withholding %

  1. #1

    Thread Starter
    Junior Member HellBunny's Avatar
    Join Date
    Feb 2011
    Posts
    25

    Visual Net Pay, Gross, & Withholding %

    Hello everyone! I'm new to visual basic... I'm currently having problems with coding this program that my teach had me do. Can anyone check the coding and see what I have done wrong? Each time I tried to build solutions error messages pop up, and the build is unsuccessful, here's the coding.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace Anon_Ch3Project
    {
    class Program
    {
    static void Main(string[] args)
    {
    int num1;
    int num2;
    int num3;
    int gross;
    int net;
    int witholding;
    int sum;


    Console.Write("How many hours have you worked? "); //# of hours worked
    num1 = Convert.ToInt32(Console.ReadLine()); //
    Console.Write("How much are you paid per hour? "); // What's your pay rate?
    num2 = Convert.ToInt32(Console.ReadLine());
    Console.Write("What's your witholding percentage: "); //# Witholding
    num3 = Convert.ToInt32(Console.ReadLine()); //

    sum = num1 * num2;
    Console.WriteLine("The Gross Pay is : {0} ", gross);

    sum = gross + num3;
    Console.WriteLine("The Net Pay is : {0} ", net);

    sum = gross * num3;
    Console.WriteLine("The Withholding is : {0} ", witholding);
    }
    }
    }



    [The project should display a title (whatever you choose for the title). The program will prompt the user for 3 things;

    * Number of hours worked
    * Their pay rate
    * Withholding percentage

    Your program will then display 3 things

    * Their gross pay
    * The withholding amount
    * The net pay]
    If anyone could help, that'd be awesome.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Visual Net Pay, Gross, & Withholding %

    Thread moved from the 'CodeBank VB.Net' forum (which is for you to post working code examples, not questions) to the 'C#' forum

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Visual Net Pay, Gross, & Withholding %

    So what's the problem? We're not mind readers. If you're getting errors, what are they?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    Frenzied Member
    Join Date
    Jan 2010
    Location
    Connecticut
    Posts
    1,687

    Re: Visual Net Pay, Gross, & Withholding %

    Welcome!!!

    Please use code tags when entering code. It makes it much easier to read.

    I see problems with your formulas:
    Code:
    sum = num1 * num2;
    Console.WriteLine("The Gross Pay is : {0} ", gross);
    You're printing gross but never assiging it a value. You are assigning a value to sum but not doing anything with it. Look over your formulas and see if you can fix them. Ask questions and we will answer them, but you may be able to fix it yourself now that I gave you a hint.
    VB6 Library

    If I helped you then please help me and rate my post!
    If you solved your problem, then please mark the post resolved

  5. #5
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: Visual Net Pay, Gross, & Withholding %

    You're getting errors when you try and use the three variables 'gross', 'net' and 'witholding' in the Console.WriteLine statements and the gross variable in the second and third assignments to sum. Look at the errors:

    "Use of unassigned local variable 'xxx'"

    What does this error suggest? It's saying that you're attempting to use a variable that has not been assigned. How to resolve this error? Assigning a value to the variable would be a logical thing to try. What value should you assign?

  6. #6

    Thread Starter
    Junior Member HellBunny's Avatar
    Join Date
    Feb 2011
    Posts
    25

    Re: Visual Net Pay, Gross, & Withholding %

    Well, I'm not getting errors but it's calculating incorrectly. I'm trying to figure out why it's doing that. The build is succeeding. I'm looking over the coding now.

  7. #7
    Frenzied Member
    Join Date
    Jan 2010
    Location
    Connecticut
    Posts
    1,687

    Re: Visual Net Pay, Gross, & Withholding %

    Did you read my post? It explains where the problem is.
    VB6 Library

    If I helped you then please help me and rate my post!
    If you solved your problem, then please mark the post resolved

  8. #8

    Thread Starter
    Junior Member HellBunny's Avatar
    Join Date
    Feb 2011
    Posts
    25

    Re: Visual Net Pay, Gross, & Withholding %

    Yes, I had read it. Thank a lot, guys! I managed to create it.

  9. #9
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: Visual Net Pay, Gross, & Withholding %

    Woot. Hopefully you learned from it too.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width