Jump to content
Banner by ~ Ice Princess Silky

technology Programmers helping Programmers


Discordian

Recommended Posts

Does anyone know what an exclusive or (XOR) means? I've come across it a few times, but I have no idea what it does. What makes it "Exclusive"?

Link to comment
Share on other sites

It is called an 'exclusive' or because it's table looks like this:

 

a    b    result

 

0    0    0

1    0    1

0    1    1

1    1    0

 

Aka, only one of the variables is allowed to be on.

Link to comment
Share on other sites

  • 1 month later...

I'm having a problem with C#... (please ignore the Finnish words and try to copy paste the words....)

 

We have to code a program that calculates how long a trip takes, but now (we're using Visual Studio 2010) I keep getting an error "The name matkanKesto does not exist in the curent context" and can't seem to find the problem....

 

I might have many problems in here, but I'm only a beginner... *wince*

 

Here's the code:

 

public class MatkanKesto

    {

        public static void Main(string[] args)

        {

            double matkanPituusKm = 124.5;

            double keskinopeusKmH = 120;

 

            double matkanKestoTunteina = MatkanKestoTunteina(matkanPituusKm, keskinopeusKmH);

            Console.WriteLine("Matka kestää " + matkanKesto + " tuntia");

            Console.ReadKey();

        }

 

        public static double MatkanKestoTunteina(double a, double  B)

        {

            matkanKesto = a * b;

            return matkanKesto;

        }

    }

 

 

 

Edited by Tenshinohana
Link to comment
Share on other sites

That is because you try to assign a variable that does not exist. Put a double in front of it and it should compile. ( Unless there are other errors )

  • Brohoof 1
Link to comment
Share on other sites

That is because you try to assign a variable that does not exist. Put a double in front of it and it should compile. ( Unless there are other errors )

 

There's still one point it says that it doesn't exist in the current context...

 

 

 Console.WriteLine("Matka kestää " + matkanKesto + " tuntia");

(the bolded part)

 

 

 

If I put in the beginning of the block "double matkanKesto;" the next error shows up... "Use of unassigned local variable".

Link to comment
Share on other sites

Oh right, didn't see you were also using it in the other method.

 

Well since you're in a class I suggest to put a 

 

double matkanKesto;

 

right before the Main method. This way you can use it in any method ( although at this point I would suggest a get/set pair but I think that is yet out of scope for you. )

Link to comment
Share on other sites

Oh right, didn't see you were also using it in the other method.

 

Well since you're in a class I suggest to put a 

 

double matkanKesto;

 

right before the Main method. This way you can use it in any method ( although at this point I would suggest a get/set pair but I think that is yet out of scope for you. )

 

That's what I did, and that's the error it gave me... Unless you mean to try to put it right after the class, but I don't think you mean that...?

Link to comment
Share on other sites

Okay, it seems there was a bit more that was off. ( I kind of didn't see that due to the different language. )

 

Here is the working code: 

 

.png

 

And it's output:

 

.png

 

If you want to know what I changed:

 

 

I renamed B to b in your second method since you used b later on and it shouldn't be uppercase anyway.

I renamed the variable in your first Console.WriteLine to the one you chose just the line above.

 


 

I suggest to also drop the uneeded variable in your second method and instantly return the result, like this:
.png

Edited by Neikicorn
Link to comment
Share on other sites

-snip-

 

 

Thank you so much!

 

I guess our professor has made a few typos that prevented me from seeing a few things. And I guess your later suggestion was actually what we were supposed to do...

 

But thanks again! ^^

Edited by Tenshinohana
Link to comment
Share on other sites

I have a good handle on HTML, XML and know the basics of Javascript, math isn't exactly my strong suit but I have shown a great deal of proficiency in computers and am trying to learn a bit more myself.

Link to comment
Share on other sites

Wow, this thread is so up my alley right now I don't believe it.  Me, I'm a CS major right now and have a basic understanding of Java, PHP, and HTML, and right now trying to learn C++.

 

In fact I have a current project in C++ that's driving me up a wall.  I'm supposed to create a program that functions as a lexer- that is, it reads in an HTML file, discards everything that isn't in a proper tag, and the output gives a count of each of the different tags found in the document.  The thing is, we're not supposed to create a predetermined list of tags- the program just reads the tags as they come in. 

 

My thought is to iteratively create a map with a key value that is a string and a mapped value that's an integer.  So when it comes across a syntactically correct tag, it checks if the tag is already in the map.  if it is, the mapped value (which would be the count) is incremented.  If it's not, the program would *add* it to the map, with a mapped value of 1. 

 

To anyone who knows C++, does this sound like it would make sense?

Link to comment
Share on other sites

If your program is supposed to only accept valid HTML then it gets really simple.

If it's not you're going to have a lot of problems when it comes to reading tags because what about tags with no closing tag? Improper nesting? ( <b><em></b></em> ) etc...

 

If you already got all that out of the way then yes, creating a Vector ( I think it's called like that in C++? )/List is the sound way of only counting the amount of a certain tag.

Link to comment
Share on other sites

Thank you so much!

 

I guess our professor has made a few typos that prevented me from seeing a few things. And I guess your later suggestion was actually what we were supposed to do...

 

But thanks again! ^^

 

What you need to remember if you have any variable. Even a temporary one which is throwaway. You always have to instance it and declare it's type the first time it is seen. Usually that it done way before any calculating is done. if your compiler ever tells you a variable doesn't exist in a context or has not be initiated, check it's first declaration and check that the variable has data in it if it is called.

Link to comment
Share on other sites

(edited)

Whoa. I see that we have a good amount of programmers 'eh?

 

I started programming (if my memory serves me right) with PASCAL language (old language I know, but pretty effective for learning). Yes, I thank God that I'm not blind yet after staring at that BSOD-like screen for so many hours. :lol:

 

Then I moved to HTML, then PHP, then SQL, etc and got a programming-less year which made my mind dull and I forgot about programming thingy. After that nasty year, I came back to PHP because my mentor asked me to try my luck again at programming. I was trying to be a network administrator that time, and not I wasn't pretty good at it, but I could stay in top-ten network engineer in my class with some burnt brain though. Those hacking and phreaking things even burnt my brain more than programming does to me now.

 

PASCAL really helped me with logic and other programming concepts, so I just needed a week to remember everything about PHP and then I moved on to another language that time. My mentor gave me a website project recently, and asked me to master six programming languages before graduate. I really want to :

 

Dear beloved Mentor,

 

"Ain't nobody got time for that."

 

Your faithful student, Wardy. (not an actual name) :lol:

 

Now I have to brainstorming with Code Igniter framework. Well, my biggest problem with web programming isn't PHP or CI, but JavaScript. Can anypony please give me a good JavaScript tutorial? Maybe something like "Learn Programming the Hard Way" but for JavaScript? Thanks. :)

 

Never mind. Just got a good one from somepony here. :lol:

 

Sincerely,
 

Wardy.

Edited by Sky Warden
Link to comment
Share on other sites

(edited)

Now I'm sure there are other bronies out there who like this type of thing as much as I do. 

And I'm sure that some of the tech admins or moderators would be happy to see something like this as well.

 

This website http://www.code.org/ has many resources on here for people who want to learn to code
All the way from basic Boolean logic minigames to full College level classes. All for free!

Now I do know HTML, CSS, basic javascript, And Lua.

But this website has resources from Unix To Python and Iso/Iec Coding languages.

 

 

Here's A short Video With Info on the Code.org Project.

 

 

Right now I'm working on basic Python as I've been meaning to Learn to use that but haven't gotten around to it.

Edited by yourmomsponies
  • Brohoof 1
Link to comment
Share on other sites

>python

 

I know somebody who will be very happy to know about this.

 


 

I can definitely endorse codecademy. Their tutorials are sound and solid.

Link to comment
Share on other sites

  • 1 year later...

I started programming in HTML, then went on to Javascript, and now working on Python. I'm a novice programmer, but sites like codecademy.com and w3schools.com helped me build my knowledge.

Link to comment
Share on other sites

I started programming in my technical high school in the IT shop. I started with JustBASIC and moved to Visual Basic before I graduated. I'm currently in college for Computer Science and have been using Java and C++. 

Link to comment
Share on other sites

I started programming in my technical high school in the IT shop. I started with JustBASIC and moved to Visual Basic before I graduated. I'm currently in college for Computer Science and have been using Java and C++. 

 

So... What's the difference between Computer Science and Computer Engineering?

Link to comment
Share on other sites

So... What's the difference between Computer Science and Computer Engineering?

 

Computer Science deals more with software while Engineering concentrates on hardware

Link to comment
Share on other sites

Computer Science deals more with software while Engineering concentrates on hardware

 

So if someone wanted to work on hardware and software at the same time, which one should they choose? I'd guess Engineering, right?

Link to comment
Share on other sites

So if someone wanted to work on hardware and software at the same time, which one should they choose? I'd guess Engineering, right?

 

It depends on what you want to work with. Engineers will work with the software like drivers for hardware while CS will work almost purely with programs you interact with on the computer itself.

Link to comment
Share on other sites

I know a little pBASIC and some C/C++. pBASIC for the BASIC Stamp which I don't care for because A. Its a derivative of BASIC (I've tried QBASIC... bad times) and a BASIC Stamp 2 costs like $50 for the uC chip alone.

 

The C/C++ comes from the Arduino platform. It's not pure C/C++, but I'm liking it thus far. I don't know too much of it but can at least do if/else, for and while loops and typically avoid globals.

 

Nice to know I may get some assistance when I inevitably invoke the Halt and Catch Fire instruction.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Join the herd!

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...