So Im writing this basic payroll tax program as an assignment , I have everything good this time except for one thing, with the multiple identifiers I have assigned to the data types when I go to write them to the output how do I tell the compiler to write all the corresponding value I know to use " {0} " but do I type "{1}" and so on for each new identifier value ?

I have attached the output I recieve when I debug the program totally different result from what should happen....

Thanks Again!

string employeeName = "Jessica Oakley";


            float takeHomePay = 28000 * (9 / 50) * (1 / 10) * (3 / 5);
            float fedTaxRate = 28000 * (9 / 50);
            float retirement = 28000 * (1 / 10);
            float socialSecurity = 28000 * (3 / 5);
            float totalSales = 28000 * (3 / 50);

            Console.Write("Name: ", employeeName);
            Console.WriteLine("The take home pay of: ", employeeName + "will be: ");
            Console.WriteLine(" {0} ", takeHomePay);
            Console.WriteLine(" ");
            Console.WriteLine("Amount of money going to Tax's {0}", fedTaxRate);
            Console.WriteLine("Amount of money going to Retirement Account {0}", retirement);
            Console.WriteLine("Amount of money going to Social Security Account {0}", socialSecurity);
            Console.WriteLine("Money earned after reciving 7% of the total sales {0}", totalSales);
            Console.Read();

Here is one of your lines

float takeHomePay = 28000 * (9 / 50) * (1 / 10) * (3 / 5);

Your problem is that all your numbers are integers, so it does integer math on them. It then converts the result into a float. So you have things like (9/50) which equals 0 (zero) times (1/10) (again zero) times (3/5) (again zero), so the result is 0 (zero).

You need to express those numbers as floats if you want floating point math. 1.0f for example

commented: helped point out a important code which was causing a problem +1

ohhhh...thank you so much Momerath

A follow up question I would have is , I have this line:

float takeHomePay = (28000f) * (0.18f) * (0.1f) * (0.06f)

what argument with identifier is there that will allow the compiler to go through the repetitious steps to multiply each percentage with 28k get that value and keep subtracting from the original value given (28000) consistently ? Is it the return type?
IF so I'm just starting to learn it so I wouldnt know if you just said "yes " ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.