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.
Programming is p lame | |||||||
---|---|---|---|---|---|---|---|
|
****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. |
||||||
Posted On: 09/22/2009 6:19PM | View Johnny Mac's Profile | # | ||||||
|
You should probably initialize decUNION_DUES. If no radio bumons are selected (could happen when page is loaded?) that’ll have no value. |
||||||
Posted On: 09/22/2009 6:29PM | View MC Banhammer's Profile | # | ||||||
|
if (rdoNone.Checked)
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 |
||||||
Posted On: 09/22/2009 6:34PM | View Psycho the CIC's Profile | # | ||||||
|
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 |
||||||
Posted On: 09/22/2009 6:47PM | View Johnny Mac's Profile | # | ||||||
|
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. |
||||||
Posted On: 09/22/2009 6:52PM | View SanDyk's Profile | # | ||||||
|
SanDyk Posted:
That’s not what my course requirements say Log in to see images! |
||||||
Posted On: 09/22/2009 7:00PM | View Johnny Mac's Profile | # | ||||||
|
With all due respect I think this thread could probably live without a bunch of “my language is better” stuff. |
||||||
Posted On: 09/22/2009 7:14PM | View Fortunato's Profile | # | ||||||
|
Johnny Mac Posted: |
||||||
Posted On: 09/22/2009 7:15PM | View SanDyk's Profile | # | ||||||
|
SanDyk Posted:
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. |
||||||
Posted On: 09/22/2009 7:17PM | View Johnny Mac's Profile | # | ||||||
|
lol M$ language Log in to see images! |
||||||
Posted On: 09/22/2009 8:54PM | View quangntenemy's Profile | # | ||||||
|
WHAT SORT OF TECHNICAL WIZARDRY IS THIS!?
WHO ARE YOU PEOPLEEEE |
||||||
Posted On: 09/22/2009 9:16PM | View Shii's Profile | # | ||||||
|
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! |
||||||
Posted On: 09/22/2009 9:21PM | View TUBSWEETIE's Profile | # | ||||||
|
TUBSWEETIE Posted: |
||||||
Posted On: 09/22/2009 9:32PM | View MC Banhammer's Profile | # | ||||||
|
I took a C# programming course and didn’t notice this thread until after the problem was solved. Log in to see images! |
||||||
Posted On: 09/22/2009 10:23PM | View Ricket's Profile | # | ||||||
|
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. |
||||||
Posted On: 09/22/2009 10:32PM | View Johnny Mac's Profile | # | ||||||
|
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. |
||||||
Posted On: 09/23/2009 12:09AM | View man-man's Profile | # | ||||||