Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

WTF am I doing wrong?

Name: Anonymous 2010-08-29 0:41

I can't for the life of me figure it out

static void Main(string[] args)
        {
            string taxcode;
            Console.WriteLine("Please enter your taxcode [A/B]: ");
            taxcode = Console.ReadLine();
            int salary;
            Console.WriteLine("Please enter your annual salary ");
            salary = Convert.ToInt32(Console.ReadLine());
            if (taxcode == " A ")
            {
                Console.WriteLine("Tax due: " + (salary * 25) / 100);
            }
            else if (taxcode == " B " (salary => 45000))
            {
                Console.WriteLine("Tax due: " + (salary * 30) / 100);
            }
            else if (taxcode == " B " (salary < 45000))
            {
                Console.WriteLine("Tax due: " + (salary * 33) / 100);
            }
        }
    }
}

Error    1    Method name expected
Error    2    Method name expected
Error    3    A local variable named 'salary' cannot be declared in this scope because it would give a different meaning to 'salary', which is already used in a 'parent or current' scope to denote something else

Name: Anonymous 2010-08-30 10:58

>>16
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TaxRates
{
    class Program
    {
        static void Main(string[] args)
        {
            string taxcode;
            int salary;
          
            Console.WriteLine("Please enter your Taxcode: [A/B]");
            taxcode = Console.ReadLine();
          
            Console.WriteLine("Please enter your anual salary:");
            salary = Convert.ToInt32(Console.ReadLine());

            if (taxcode == "A")
            {
                Console.WriteLine("Tax due: {0}", (salary * 25) / 100);
            } else if ((taxcode == "B") || salary >= 45000) {
                Console.WriteLine("Tax due: {0}", (salary *30) / 100);
            } else if ((taxcode =="B") || salary < 45000) {
                Console.WriteLine("Tax due: {0}", (salary * 35) / 100);
            }
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Please press enter to exit.");
            Console.ReadLine();
        }
    }
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List