|
-
Feb 6th, 2011, 08:40 PM
#1
Thread Starter
Junior Member
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.
-
Feb 7th, 2011, 06:48 AM
#2
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
-
Feb 7th, 2011, 07:59 AM
#3
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
-
Feb 7th, 2011, 08:17 AM
#4
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
-
Feb 7th, 2011, 05:25 PM
#5
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?
-
Feb 9th, 2011, 01:19 PM
#6
Thread Starter
Junior Member
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.
-
Feb 9th, 2011, 01:22 PM
#7
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
-
Feb 25th, 2011, 01:30 PM
#8
Thread Starter
Junior Member
Re: Visual Net Pay, Gross, & Withholding %
Yes, I had read it. Thank a lot, guys! I managed to create it.
-
Feb 25th, 2011, 02:31 PM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|