OT: Does anyone here know C#? ... * Student Question *

mallorz

Member
Join Date
Oct 2011
Location
W
Posts
61
Hello...

I am in my second week of an online Beginning .NET class. We have an assignment that is supposed to simulate a basic payroll-type function. I am getting an error on one of my statements but am unsure why.

At the beginning of the program, I define two constants STATE_TAX and FED_TAX. I define them out as doubles because they are decimals (0.05, 0.15). When I call them out in a statement ( double fedTax = Convert.ToDouble(grossPay) * FED_TAX ) the program stops running and I get an error.

I've attached a screen shot of the message and also a .txt document of the code.

Does anyone know what I'm doing wrong? They are all 'doubles' so I understand how "the input string was not in the correct format"

SchoolProgram.jpg
 

Attachments

  • school.txt
    2 KB · Views: 16
I should add, try to ignore the unnecessary Console.ReadLines() and such. I forgot to delete them from having issues the other day! I'll touch up all the formatting when I get this thing figured out.
 
Oui. It appears you are right! That's what happens I guess when you stare at something too long.

Started this assignment on Sunday, it has 4 parts to it. Finished 1-2 on Sunday.. that was easy. Wrote 3 (this one) and then tested it Monday. Spent a few hours after work on Monday on it and just got frusterated beyond belief!

Thank you very much! I appreciate you taking the time to look at it.
 
I agree with Ken;

fedtax = grosspay*FED_TAX; (Think that's what your grosspay variable is, although can't see the pic that well).
 
For future reference, I'm fairly dangerous (re: competent but sometimes unsure) with C#. I you can PM me if need be.

Haha, thank you! I really appreciate that. I am so hard on myself that once I get to a certain point with a program it's like my brain shuts off. Sometimes it just takes fresh eyes to see the obvious :)
 

Similar Topics

Hi there, I need to work on a GE series 5 PLC which need DOS based Logic Master 5, it seems like nowhere I can purchase this software anymore...
Replies
2
Views
943
This is something we have utilized before I ever took over the HMI development going clear back into the Windows XP era; We and I think Rockwell...
Replies
1
Views
4,664
I have been asked where to get pro face Hmi software from, I have been told that it's a free download but I am not sure can anyone help thanks stu
Replies
2
Views
5,162
Does anyone know where can I find a tiny PLC with one input and one output? The Tri-PLC is too big for my application. I need to embed this into a...
Replies
15
Views
5,934
Replies
8
Views
2,230
Back
Top Bottom