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

Pages: 1-

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-29 0:41

>>1
Everything

Name: Anonymous 2010-08-29 0:55

first of all => should be >=
secondly, &&. ie else if (taxcode == " B " && (salary < 45000))

Name: Anonymous 2010-08-29 0:56

>>1
I'm going to take a shot in the dark because I really don't know this language (is this C#?).  I think it's trying to turn
" B " (salary => 45000)
" B " (salary < 45000)

into methods, under the assumption that they (were intended to) return boolean values.

Name: Anonymous 2010-08-29 1:00

OP why are you using C#?

Name: Anonymous 2010-08-29 1:03

>>5
Because I'm studying Computing and Math sciences at Uni and thats what we use.

Name: Anonymous 2010-08-29 1:10

>>6
study harder, friend.

Name: Anonymous 2010-08-29 1:22

>>1
Sorry, I cannot help you, as your braces style is turning my eyes inside out.

Name: Anonymous 2010-08-29 5:22

>>8
That's what you get for reading code without [code] tags.

Name: Anonymous 2010-08-29 12:40

Are all the C# compilers so shitty you can't see nothing behind those nothing-telling error messages?

Name: Anonymous 2010-08-29 13:28

string[] args

Name: Anonymous 2010-08-29 13:30

>>11

Never mind wrong language. Thought you were using the superior Java.

WTF am I doing wrong?

You are using proprietary Microsoft bullshit.

Name: Anonymous 2010-08-29 13:34

>>12
Proprietary Oracle bullshit isn't any better. In fact, it's worse. Microsoft promised they won't sue you for using a non-Microsoft implementation, while Oracle will sue you if they think you have enough money.

Name: Anonymous 2010-08-29 13:55

the superior Java
Well, I guess now we know exactly how idiotic the people who can't even manage to sage are.

Name: Anonymous 2010-08-29 18:49

Here you go, works fine for me.

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();
        }
    }
}

Name: Anonymous 2010-08-29 22:04

What is it about Cocktothorpe enthusiasts that renders them unable to place braces properly and use [code] tags?

Name: Anonymous 2010-08-29 22:45

>>16
If you think that

main(string[] args){
}

is proper style, you are clearly retarded

Name: Anonymous 2010-08-29 22:47

>>17
That is correct. You need a space before the ``{''.

Name: Anonymous 2010-08-29 23:07

>>17
If you think >>15 used K&R style, you need to read K&R again.

Name: sage 2010-08-30 1:12

>>16
How do I use [code] tags properly then?

Name: Anonymous 2010-08-30 1:18

[code]

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();
        }
    }
}

Name: Anonymous 2010-08-30 11:15

Oh god this is hideous.

Name: Anonymous 2010-08-30 11:29

>>22
            if (taxcode == "A")
            {

You only dealt with half of >>16-kun's complaints.

Name: Anonymous 2010-08-30 12:22

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Please press enter to exit.");

Woah there, cowboy! Don't they explain escape sequences at the Microsoft Summer Camp?

Name: Anonymous 2010-08-30 12:40

>>25
Maybe he wants to be extra certain that his program makes those blank lines despite all chances of failure.

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