Forumwarz is the first "Massively Single-Player" online RPG completely built around Internet culture.

You are currently looking at Flamebate, our community forums. Players can discuss the game here, strategize, and role play as their characters.

You need to be logged in to post and to see the uncensored versions of these forums.

Log in or Learn about Forumwarz

Civil Discussion
Switch to Role-Playing Civil Discussion
Fix It Programming is p lame

Johnny Mac

Avatar: 37704 2011-07-31 00:49:39 -0400
35

[Full of SbumSS]

Level 35 Troll

hot horse great times lover

****ing radio bumans.

namespace CS5
{
    public partial clbum CS5Form : Form
    {
        public CS5Form()
        {
            InitializeComponent();
        }

        //Declaring clbum-level variables
        int cintEmployeeCount;
        decimal cdecTotalNetPay;

        const decimal cdecNONE_UNION_DUES = 0.00M;
        const decimal cdecREGULAR_UNION_DUES = 5.00M;
        const decimal cdecSPECIAL_UNION_DUES = 10.00M;
        const decimal cdecFEDERAL_RATE = 0.15M; //(15%)
        const decimal cdecFICA_RATE  = 0.06M; //(6%)
        const decimal cdecSTATE_RATE = 0.05M; //(5%)
   
	      
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            //Declaring method variables
            int intHoursWorked;
            decimal decPayRate;
            decimal decGrossPay;
            decimal decFICATax;
            decimal decStateTax;
            decimal decFederalTax;
            decimal decNetPay;
            decimal decAverageNetPay;
            decimal decUnionDues;
            decimal decUNION_DUES;

            try
            {
                //Values input into the calculator
                intHoursWorked = int.Parse(txtHoursWorked.Text);
                decPayRate = decimal.Parse(txtPayRate.Text);
                try
                {
                    
                    //Processes to calculate various values.
                    if (intHoursWorked <= 40)
                        decGrossPay = intHoursWorked * decPayRate;
                    else
                        decGrossPay = (40 * decPayRate) + ((intHoursWorked - 40) * decPayRate * 1.5M);

                    if (rdoNone.Checked)
                        decUNION_DUES = cdecNONE_UNION_DUES;
                    else
                    if (rdoRegular.Checked)
                        decUNION_DUES = cdecREGULAR_UNION_DUES;
                    else
                    if (rdoSpecial.Checked)
                        decUNION_DUES = cdecSPECIAL_UNION_DUES;

                    decFICATax = decGrossPay * cdecFICA_RATE;
                    decFederalTax = decGrossPay * cdecFEDERAL_RATE;
                    decStateTax = decGrossPay * cdecSTATE_RATE;
                    decNetPay = decGrossPay - (decFICATax + decFederalTax + decStateTax + decUNION_DUES);
                    decUnionDues = decUNION_DUES;
                    decUNION_DUES = decUnionDues;

 
                    cdecTotalNetPay += decNetPay;
                    cintEmployeeCount += 1;
                    decAverageNetPay = cdecTotalNetPay / cintEmployeeCount;
                    


                    //Output variables to display
                    lblGrossPay.Text = decGrossPay.ToString("C"); //Displayed as currency
                    lblFICATax.Text = decFICATax.ToString("C");
                    lblFederalTax.Text = decFederalTax.ToString("C");
                    lblStateTax.Text = decStateTax.ToString("C");
                    lblUnionDues.Text = decUnionDues.ToString("C");
                    lblNetPay.Text = decNetPay.ToString("C");

                    lblTotalNetPay.Text = cdecTotalNetPay.ToString("C");
                    lblEmployeeCount.Text = cintEmployeeCount.ToString("#"); //Displayed as integer
                    lblAverageNetPay.Text = decAverageNetPay.ToString("C");
                }

                //Pay Rate errors
                catch (FormatException err)
                {
                    MessageBox.Show("Pay Rate must be numeric. " + err.Message,
                     "Data Entry Error", MessageBoxbumons.OK,
                     MessageBoxIcon.Exclamation);
                    txtPayRate.SelectAll();
                    txtPayRate.Focus();
                }
            
                }
                 
                 //Hours Worked errors
                 catch (FormatException err) 
                {  
                    MessageBox.Show("Hours worked must be numeric. " + err.Message, 
                     "Data Entry Error", MessageBoxbumons.OK, 
                     MessageBoxIcon.Exclamation); 
                    txtHoursWorked.SelectAll(); 
                    txtHoursWorked.Focus();
                } 
                   catch (Exception err)
                {
                   MessageBox.Show("Unexpected Error: " + err.Message);
                }
          
		}//end of btnCalculate


        private void btnClearForm_Click(object sender, EventArgs e)
        {
            //Clearing text boxes
            txtHoursWorked.Clear();
            txtPayRate.Clear();

            //Null string Labels
            lblGrossPay.Text = "";
            lblFICATax.Text = "";
            lblStateTax.Text = "";
            lblFederalTax.Text = "";
            lblUnionDues.Text = "";
            lblNetPay.Text = "";
            lblTotalNetPay.Text = "";
            lblEmployeeCount.Text = "";
            lblAverageNetPay.Text = "";

            //Resetting acgreat timesulators
            cdecTotalNetPay = 0;
            cintEmployeeCount = 0;

            rdoNone.Checked = true;

            txtHoursWorked.Focus();
 
        }//end of btnClearForm


        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        //end of btnExit


    }//end of clbum
}//end of namespace

decUNION_DUES in

decNetPay = decGrossPay – (decFICATax + decFederalTax + decStateTax + decUNION_DUES);

is giving me a use of unbumigned local variable.

I don’t expect an answer to my problem, I just wanna cry about it.

Also give me an answer.

MC Banhammer

Avatar: 1887 2011-07-31 00:40:59 -0400
36

[Good Omens]

Level 69 Troll

Trying to create drama to drum up the ratings by any means necessary!

You should probably initialize decUNION_DUES. If no radio bumons are selected (could happen when page is loaded?) that’ll have no value.

Psycho the C-
IC

Avatar: 196206 Mon Jul 27 20:52:24 -0400 2009
4

[Team Nakama]

Level 35 Hacker

“43 4f 44 45 20 4d 41 53 54 45 52”

if (rdoNone.Checked)

decUNION_DUES = cdecNONE_UNION_DUES;

else

if (rdoRegular.Checked)

decUNION_DUES = cdecREGULAR_UNION_DUES;

else

if (rdoSpecial.Checked)

decUNION_DUES = cdecSPECIAL_UNION_DUES;

The interpreter (is that JavaScript?) is whining that the variable won’t be initialized if none of the conditions is satisfied. (even if it’s impossible)

bumigning a default value before this part should solve it…

Edit: Whoops, too late.

Psycho the CIC edited this message on 09/22/2009 6:35PM

Johnny Mac

Avatar: 37704 2011-07-31 00:49:39 -0400
35

[Full of SbumSS]

Level 35 Troll

hot horse great times lover

Hurf durf, yeah that worked. My mind was thinking that the error was being caused by another issue. Still goth plenty of work to do now. Log in to see images!

Btw it’s C#

Johnny Mac edited this message on 09/22/2009 6:47PM

SanDyk

Avatar: 175636 2012-01-01 09:50:12 -0500
21

[Grey Goose Mafiosi]

Level 69 Troll

I am the internet equivelent of Jon Stewart! Except less funny...

petition to change the title of this topic to “programming in C# is p lame”

seriously there’s plenty of other decent languages you could use instead.

Johnny Mac

Avatar: 37704 2011-07-31 00:49:39 -0400
35

[Full of SbumSS]

Level 35 Troll

hot horse great times lover

SanDyk Posted:

petition to change the title of this topic to “programming in C# is p lame”

seriously there’s plenty of other decent languages you could use instead.

That’s not what my course requirements say Log in to see images!

Fortunato

Avatar: 72902 2010-02-03 18:45:17 -0500
32

[Grey Goose Mafiosi]

Level 51 Troll

ZOMBIE CANNONBALL OF GORE

With all due respect I think this thread could probably live without a bunch of “my language is better” stuff.

SanDyk

Avatar: 175636 2012-01-01 09:50:12 -0500
21

[Grey Goose Mafiosi]

Level 69 Troll

I am the internet equivelent of Jon Stewart! Except less funny...

Johnny Mac Posted:

That’s not what my course requirements say Log in to see images!

What course are you doing to do C#?

Johnny Mac

Avatar: 37704 2011-07-31 00:49:39 -0400
35

[Full of SbumSS]

Level 35 Troll

hot horse great times lover

SanDyk Posted:

What course are you doing to do C#?

It’s just a basic requirement for my CIS major, first harder programming I’ve had to do. Only in my second year of college atm.

quangntenemy

Avatar: 14557 2011-10-31 11:07:55 -0400
59

[WeChall]

Level 69 Troll

:ronpaul: :****ing sucks:

lol M$ language Log in to see images!

Shii

Avatar: 23167 2010-01-24 16:31:18 -0500
27

[Phantasmagoric Spl-
endor
]

Level 35 Emo Kid

I haven't seen a bad idea that I didn't like.

WHAT SORT OF TECHNICAL WIZARDRY IS THIS!?

WHO ARE YOU PEOPLEEEE

TUBSWEETIE

Avatar: 3450 2011-07-31 00:45:06 -0400
28

[And The Banned Pla-
yed On
]

Level 37 Troll

MY MEMORY IS THAT OF A SMALL GRAPE

posting to say programmins is p awesome. recent events have shown that.

sadly i dont know this language and am of no use Log in to see images!

MC Banhammer

Avatar: 1887 2011-07-31 00:40:59 -0400
36

[Good Omens]

Level 69 Troll

Trying to create drama to drum up the ratings by any means necessary!

TUBSWEETIE Posted:

i dont know this language and am of no use Log in to see images!

I don’t know this language either, but I was of use. Boo-yah!

Ricket

MODERATOR
Avatar: 4300 2011-11-01 00:56:47 -0400
100

[The Scrotal Safety-
Commission
]

Level 69 Troll

Good poster, upvoted.

I took a C# programming course and didn’t notice this thread until after the problem was solved. Log in to see images!

Johnny Mac

Avatar: 37704 2011-07-31 00:49:39 -0400
35

[Full of SbumSS]

Level 35 Troll

hot horse great times lover

Only thing I couldn’t figure out was how to make a radio buman selected at startup. I thought it was just

rdoNone.Checked = true;

But I could only throw that in an area where you had to select a buman.

I got around it just by making the default value equal to the one I needed, so it works properly, just doesn’t display the default option is checked.

Instructor is lenient as hell, I bet I’ll get like 1% off, if that for it.

man-man

Avatar: 156485 2010-01-24 16:36:14 -0500
24

[Harem and Sushi Bar]

Level 69 Hacker

Selfish fine upstanding member of society

You could initially bumign it an arbitrary invalid value; something it’s never going to get set to in any way other than being initialised that way. Then you can include a “click one of the radio bumons you bumhole” error message for if it has that specific value when the calculations are run.

Would that work? I don’t know this language, and my programming experience is extremely limited, but I can guess at what things mean and it seems like that should work, even if it is a bit ugly to put something invalid in as the initial value.

Internet Delay Chat
Have fun playing!
To chat with other players, you must Join Forumwarz or Log In now!