Programming for Idiots (C#) - Take 2

06/30/2012 23:29 funkymonkey#136
"getting started" file not found.... can u reupload please?
07/01/2012 07:45 xMarline#137
Please reupload them [ Uint One] Lesson Three & Lesson Nine] [Uint Two] leasson One & two & six & Thanks :)
07/01/2012 09:01 Zeroxelli#138
Check [Only registered and activated users can see links. Click Here To Register...]
07/03/2012 07:59 Silent-Death#139
ROFL!

I`m actually having some fun with the 'homework' Inf is giving in these tuts.

Check this one out lol:

Quote:
A group of three people attempt to walk into a bar. They must show their ID which indicates their age before they enter. Your program will take the input of these three ages and tell them if they’re too young to enter (consider if a person is 18 or older they are allowed to enter).
Now thing is from that they I understood something like if one is over 18 he can be the supervisor for the other two so they can all enter. Didn`t understand why the need for the while since it`s the while lesson =))

This is inf's solution:
Code:
        static void Main(string[] args)
        {
            int j = 0;
            while (j < 3)
            {
                int age = int.Parse(Console.ReadLine());
                if (age >= 18)
                {
                    Console.WriteLine("Enjoy your stay");
                }
                else
                {
                    Console.WriteLine("Sorry kiddo. Too young.");
                }
		    j++;
            }
        }
this was mine:
Code:
static void Main(string[] args)
        {
            int a1 = int.Parse(Console.ReadLine());
            int a2 = int.Parse(Console.ReadLine());
            int a3 = int.Parse(Console.ReadLine());
            int i = 0;

            while (i < 1)
            {
                if (a1 >= 18)
                {
                    Console.WriteLine("You may enter . 1");
                }
                else if (a2 >= 18)
                {
                    Console.WriteLine("You may enter . 2");
                }
                else if (a3 >= 18)
                {
                     Console.WriteLine("You may enter . 3");
                }
                else
                {
                    Console.WriteLine("Go home kids..");
                }
                i++;
            }
            Console.ReadKey();
        }
Seriously, if you are new to c# and dunno where to start, check these lessons out. They are fun =)
07/03/2012 08:21 Zeroxelli#140
Quote:
Originally Posted by Silent-Death View Post
ROFL!

I`m actually having some fun with the 'homework' Inf is giving in these tuts.

Check this one out lol:



Now thing is from that they I understood something like if one is over 18 he can be the supervisor for the other two so they can all enter. Didn`t understand why the need for the while since it`s the while lesson =))

This is inf's solution:
Code:
        static void Main(string[] args)
        {
            int j = 0;
            while (j < 3)
            {
                int age = int.Parse(Console.ReadLine());
                if (age >= 18)
                {
                    Console.WriteLine("Enjoy your stay");
                }
                else
                {
                    Console.WriteLine("Sorry kiddo. Too young.");
                }
            j++;
            }
        }
this was mine:
Code:
static void Main(string[] args)
        {
            int a1 = int.Parse(Console.ReadLine());
            int a2 = int.Parse(Console.ReadLine());
            int a3 = int.Parse(Console.ReadLine());
            int i = 0;

            while (i < 1)
            {
                if (a1 >= 18)
                {
                    Console.WriteLine("You may enter . 1");
                }
                else if (a2 >= 18)
                {
                    Console.WriteLine("You may enter . 2");
                }
                else if (a3 >= 18)
                {
                     Console.WriteLine("You may enter . 3");
                }
                else
                {
                    Console.WriteLine("Go home kids..");
                }
                i++;
            }
            Console.ReadKey();
        }
Seriously, if you are new to c# and dunno where to start, check these lessons out. They are fun =)
Hmm.. well, you get the three input values without actually asking them, so they have to KNOW to enter a number three different times before seeing any output. Also, you don't need a while if you're going to only do something once, it's a waste of machine code :p Here's a C++ example (Could use while, but meh.)

Code:
#include <iostream>
#include <stdlib.h>

typedef unsigned char byte;

int main(int argc, char* argv[])
{
    byte Age = 0;
    std::string _age;
    for (byte b = 0; b < 3; b++)
    {
        std::cout << (Age == 0 ? "Hey kid, how old are you?: " : "What about you, how old are you?: ");
        std::cin >> _age;
        Age = atoi(_age.c_str());
        if (Age >= 18)
            std::cout << "Okay kid, go ahead." << std::endl;
        else
            std::cout << "Sorry kid, go home." << std::endl;
    }
    return 0;
}
07/03/2012 08:51 Silent-Death#141
Quote:
Originally Posted by Zeroxelli View Post
Hmm.. well, you get the three input values without actually asking them, so they have to KNOW to enter a number three different times before seeing any output. Also, you don't need a while if you're going to only do something once, it's a waste of machine code :p Here's a C++ example (Could use while, but meh.)

Code:
#include <iostream>
#include <stdlib.h>

typedef unsigned char byte;

int main(int argc, char* argv[])
{
    byte Age = 0;
    std::string _age;
    for (byte b = 0; b < 3; b++)
    {
        std::cout << (Age == 0 ? "Hey kid, how old are you?: " : "What about you, how old are you?: ");
        std::cin >> _age;
        Age = atoi(_age.c_str());
        if (Age >= 18)
            std::cout << "Okay kid, go ahead." << std::endl;
        else
            std::cout << "Sorry kid, go home." << std::endl;
    }
    return 0;
}
aye i know lol.. that is why i was wondering about why implementing while but it was the lesson about while so i just put one in =)

ffs =))
Code:
whie (a < 1)
{
a++
}
who the hell does that =)) that`s why i posted it, for the lols :))
07/03/2012 17:34 Zeroxelli#142
Quote:
Originally Posted by Silent-Death View Post
aye i know lol.. that is why i was wondering about why implementing while but it was the lesson about while so i just put one in =)

ffs =))
Code:
whie (a < 1)
{
a++
}
who the hell does that =)) that`s why i posted it, for the lols :))
I guess it does prove a point, that while loops can be used the same way, I don't use them that often, though.
07/03/2012 18:03 Silent-Death#143
yea i work with for's too.
02/05/2013 00:34 spearking#144
can you update the links?.....nd sure unit 2 Lesson 2 one....?!
07/02/2013 23:15 kiko8koki#145
All the links aren't working.
10/16/2013 02:06 skykaiwen#146
I think need someone to re-upload all the files again for those who really want to learn it.
10/16/2013 06:52 Spirited#147
Closed until notice is given from the original poster. The links have been dead for months now, and we really don't need this to be bumped every few months or so.