Thursday, March 29, 2012

Keeping Myself On Task

It's embarrassing and corny, but I'm going to start posting all of my excercises from Liberty's C# book on my blog.  CodeYear has built-in nags and bells that keep you working on the exercises, and I can access the site from Wally.  It's been too easy to use the excuse that it's hard to book time on the "big" computer (which can run Visual Studio) and simply read and make notes for C#.

Without further ado (because writing a clever post would be just one more thing to delay me), here is what I'm working on right now:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Exercise_7_2
{
    class Math
    {
        public static void Add(int num1, int num2)
        {
            Console.WriteLine("{0} + {1} = {2}", num1, num2, num1 + num2);
        }
        public static void Subtract(int num1, int num2)
        {
            Console.WriteLine("{0} - {1} = {2}", num1, num2, num1 - num2);
        }
        public static void Multiply(int num1, int num2)
        {
            Console.WriteLine("{0} X {1} = {2}", num1, num2, num1 * num2);
        }
        public static void Divide(int num1, int num2)
        {
            Console.WriteLine("{0} / {1} = {2}", num1, num2, num1 / num2);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Math.Add(1, 2);
            Math.Subtract(3, 2);
            Math.Multiply(3, 5);
            Math.Divide(81, 9);
            // to keep the little console window open :)
            Console.Read();
        }
    }
}

edited to show slight change in code...

1 comment:

  1. Ok, most exercises. At least one a day. It will be like looking back at old kindergarten fingerpaintings. (I hope...)

    ReplyDelete

Comments? Questions? Complaints? Coladas?