Friday, August 26, 2011

Life 2.0

Well followers, after a long Summer of working outdoors mowing grass, weeding flowerbeds, trimming hedges and, dare I say it... NOT PROGRAMMING??? I have returned to provide more code, and offer my services as a technician. If anyone has any computer problems, please let me know. I may be of some assistance. I know Windows XP and 7 environments as well as Linux kernels Fedora and Ubuntu.

This semester I'll be learning a bit of SQL (Structured Query Language), and some more Java (yum!). I may read up on a bit of C++ from my reference books at home, and I'm also learning more HTML/XHTML this semester as well. This is my 2nd year in my 3 year program, so the 2.0 seems a bit fitting. Still needs a bit of refining, but that will come in later patches. :P

I'll write some code here starting next week. Just taking this week to get things squared away first.

Hold Your Head High
~DanceLink

Monday, May 9, 2011

Final Exam Code

Hello World!

I might as well give everyone an update as to what's going on for the summer with me.

I'll be working Full-Time (and then some) as a landscaper for my old boss in Montreal to save up some money for my future endeavors next semester, but aside from that I have almost finished my 2nd semester in Computer Sciences at my school, just another 2 years to go, and then I'm off into my field in the workforce (enough of this part-time doughnut shop stuff).

I also thought it'd be a good idea to post the code from my final exam. It's a simple program, but it's from the programming portion of the final exam I had (compared to the multiple choice and True/False portions). Code is originally mine, though I'm sure a lot of my classmates got similar answers.

Here is the correct code for the program to work according to the outline of the exam:

package Programming_2;
import java.util.Scanner;
import java.io.*;

/**
 * @author A. Wright
 * @version 1.0
 * @date May 9, 2011
 * This program was on the final exam for the author's programming course.
 * The following is the correct code made to have a number of products inputed with
 * serial numbers, pricing information, and quantities for each product. The returned
 * value is the total quantity of items among the different products.
 */

public class Final_Exam_Question {

    public static void main(String[] args)
    {
        Scanner kb = new Scanner(System.in);
        String[] productID;
        double[] price;
        int[] quantity;
        int size = 0; //Default
       
        System.out.println("Please enter the number of products: ");
        size = kb.nextInt();
       
        productID = new String[size];
        price = new double[size];
        quantity = new int[size];
       
        for(int i = 0; i < size; i++)
        {
            System.out.println("Please enter the following information for product: "+(i+1));
            System.out.println("Product ID Number: ");
            productID[i] = kb.next();
            System.out.println("Price: ");
            price[i] = kb.nextDouble();
            System.out.println("Quantity: ");
            quantity[i] = kb.nextInt();
        }       
        System.out.println("The total quantity of products is: "+totalQuantity(quantity));       
    }
   
    public static int totalQuantity(int[] qty)
    {
        int total = 0;       
        for(int j = 0; j < qty.length; j++)
        {
            total += qty[(j)];           
        }
        return total;
    }   
}

Till next time.

Hold Your Head High
~DanceLink

Tuesday, April 26, 2011

Computer, Status: Online

Well, after much time and effort, I have finally implemented a solution to my Ubuntu problem, basically after I was able to access my partition, I created a sort of "escape pod" for all the data on that partition I did not want to lose onto an old USB key of mine. After that was done, I basically reformatted the Ubuntu partition, and the swap partition Ubuntu uses, then I re-installed Ubuntu 10.10 Maverick onto my laptop. Now that it boots up properly, I'll be able to work on the go for the last of my assignments before the end of my semester in 2 weeks, particularly my Java assignments.

For more information on how I fixed my laptop, go to my Ubuntu thread at Ubuntu Forums.

I will say this, although it's not my ideal solution, the above solution does work. I would honestly rather have had to just repair whatever files were missing and/or corrupt, that way I could just get back into that partition where I left off, but like I said earlier, the applied solution above works as well.

Now to finish my Java assignments, then it's just a matter of studying for my finals, finishing my semester, and then working full-time during the summer for some of my goals for the upcoming semester.

Hold Your Head High!
~DanceLink 

Monday, April 4, 2011

Ubuntu

Hello dear readers!

I have been, other than really busy, trying to get my laptop back up and running properly. For the past 2 LONG weeks, I have been running off of recovery modes from 2 different versions of the Ubuntu Linux Kernels.

Reason being, the partition on my laptop that holds the Ubuntu 10.10 Notebook Version will not initialize on bootup. For whatever reason, it gives me the following error message on bootup when the bootloader program GRUB initializes:

Out of Disk

I have been looking online at some linux/Ubuntu forums to try to fix this, but the main solutions involve what's called 'mounting' the partition to the recovery disk (a.k.a. Live CD/USB). For you linux noobs, consider this, in Windows, when you insert a USB device into your computer, the OS (Operating System) creates a link (or mount point) in "My Computer" for you to open the folders in the USB drive and view what's inside; thus the USB Drive is 'mounted' in "My Computer".

What I need to try to do is to mount the linux partition of my hard drive to my Live CD/USB to fix it. Problem being: the partition seems to be busy and will not mount, like having a flash drive busy with something and constantly telling the computer "I'll get back to you in a bit".

Now, if the data on the partition weren't important, I'd just re-format that partition and start over. Problem #2 being: All my current school-related files are on that partition, and I can't access them. So I'm stuck, because my laptop will not load the Windows OS or the linux kernel, so the only way I can use this machine right now is by booting off of recovery versions of Ubuntu where I can't even save any data.

I'll hopefully be able to get my system back up and running by the end of the semester. I just haven't made the decent chance to really sit down and break my back trying to get this thing working properly again.

Here's hoping.

Hold Your Head High
~DanceLink

Wednesday, March 2, 2011

Busy Schedules!

Good morning world!

I realize I haven't been blogging a whole lot lately, but that does come with a few very valid reasons, well one really... I've been extremely, and incredibly busy as of late.

I take 5 daytime courses 5 days a week, as well as working 32 hours a week at a Tim Hortons shop near my place doing graveyard hours from 10pm-6am the following morning, and I usually have a class 4 hours later if not less. Fun, right?

Onto the main post, I'm actually considering doing some contract web development work after, at the very least, this current semester. Not quite sure how I'm going to go about it just yet, but I figure I'll look into some sample contracts to see what I can write up, as well as shop around for comparative prices.

I'd actually really like the opinions and comments of my readers regarding this. I've never done contract work before, save for working in landscaping in the past for a company, and all our work composed of the contracts my former employer had.

I will try to post more often, but in the event that I don't, it's really because I'm, as several people have put it, "burning the wick at both ends".

Hold Your Head High
~DanceLink

Monday, January 31, 2011

Computer Specs

Hello all! First off, I'd like to welcome our newest follower, Michael Cabana! Thanks so much for helping to spread the word about this blog. I should start posting more often if I'm going to be getting more and more followers. ^.^

On to the topic at hand, so far, I've posted samples of my work in the past pertaining to Java Code, I should be able to post some XHTML in the upcoming weeks, so look forward to that, but more importantly, I wanted to share my abilities as a technician when it comes to the physical hardware we commonly call a "Personal Computer".

Since 2005, I have personally, single-handedly, and successfully assembled 2 Home Computer Systems from parts bought at a MicroBytes outlet in Pointe-Claire, installed all the corresponding software myself, and configured the systems to work properly using Windows Operating Systems. My system from 2005 has been dismantled due to lack of performance and outdated technology (R.I.P.), but my latest system is one I assembled this past Summer (2010) using Windows 7 Home Premium as the OS, though I'm attempted to install the Ubuntu Desktop 10.10 Kernel onto it, but am having trouble with the bootloading process.

Regardless, here are my currect system's technical specs:

OS: Microsoft Windows 7 Home Premium (64-bit)
Processor: AMD Athlon(tm) II X2 250 Processor 3.00 GHz
RAM Installed: 2 GB DDR3 RAM
Primary HDD: Western Digital WDC WD1001FALS-00J7B0 (1 TB)
Secondary HDD: Seagate Technology ST380011A (80 GB)
Graphics Card: ATI Radeon 5750

That's about all I can think of putting on there for now. The system itself cost me with the OS CD about $850 CDN plus change and taxes. I do plan on getting more RAM at some future point, might go with Triple-Channeling 4 GB Modules.

Stay Tuned for more updates!

~DanceLink

Monday, January 17, 2011

Updated Code

Good Morning World! As I start yet another semester learning to make new, better codes, I'd like to post an update to one of my codes I previously posted for calculating the estimate cost of items purchased after applying Sales Taxes in the Province of Quebec, Canada.

Previously, the effective sales tax in Quebec was 7.875% (QST) and the sales tax across Canada is 5% (GST), making a total tax rate of 12.875% for Sales Taxes combined in Quebec (QST+GST) for the year 2010.

Currently, the effective sales tax in Quebec is 8.925% (QST) and the sales tax across Canada is 5% (GST), making a total tax rate of 13.925% for Sales Taxes combined in Quebec (QST+GST) for the year 2011.

The following code can be used as a dummy program imitating a cash register at any general store (Grocery, Fast Food, Restaurant, etc.).

Stay tuned...

~DanceLink

-------------------------------------------------------------------------------------------------------------

import java.util.Scanner;
import java.text.NumberFormat;
public class QC_Price {

    /**
     * This program is intended to approximate the total cost of items purchased after taxes.
     * @author A. Wright
     * @version 1.1, January 2011
     */
    public static void main(String[] args) {
        Scanner kb = new Scanner(System.in);
        double PST=0.08925, GST=0.05;
        double subtotal=0,total;
        int op1, items;
        double[] prices;
        NumberFormat currencyFormatter;
       
        System.out.println("Would you like to:"
                        +"\n1.Calculate sub-total AND total costs?"
                        +"\n2.Calculate ONLY total cost?");
        op1=kb.nextInt();
        while(op1<1||op1>2){
            System.out.println("That is not a valid option.\nPlease enter a valid option:");
            System.out.println("Would you like to:"
                    +"\n1.Calculate sub-total AND total costs?"
                    +"\n2.Calculate ONLY total cost?");
            op1=kb.nextInt();
        }
        if(op1==1){
            System.out.println("Please enter number of items to be inputed:");
            items=kb.nextInt();
            while(items<0){
                System.out.println("That is not a valid number.\nPlease enter a positive value:");
                System.out.println("Please enter number of items to be inputed:");
                items=kb.nextInt();
            }
            if(items==0){
                System.out.println("No item quantity was specified.\nSystem aborting operation.");
                System.exit(0);
            }
            prices=new double[items];
            System.out.println("Please enter item prices as advertized:");
            for(int i=0;i<items;i++){
                System.out.print((i+1)+". ");
                prices[i]=kb.nextDouble();
                subtotal += prices[i];
            }
            String currencySubtotal,currencyGST,currencyPST,currencyTotal;
            currencyFormatter=NumberFormat.getCurrencyInstance();
            currencySubtotal=currencyFormatter.format(subtotal);
            currencyGST=currencyFormatter.format(((subtotal*GST)));
            currencyPST=currencyFormatter.format(((subtotal*PST)));
            System.out.println("The subtotal amount is: "+currencySubtotal+" CDN.");
            total=subtotal+(subtotal*(GST+PST));
            currencyTotal=currencyFormatter.format(total);
            System.out.println("The total GST amount is: "+currencyGST+" CDN.");
            System.out.println("The total PST amount is: "+currencyPST+" CDN.");
            System.out.println("The total amount is: "+currencyTotal+" CDN.");
            System.exit(0);
        }
       
        if(op1==2){
        System.out.println("Please enter sub-total costs:");
        subtotal=kb.nextDouble();
        while(subtotal<0){
            System.out.println("That is not a valid price.\nPlease enter a positive value:");
            System.out.println("Please enter sub-total costs:");
            subtotal=kb.nextDouble();
        }
        total=subtotal+(subtotal*(GST+PST));
        String currencysubtotal,currencygst,currencypst,currencytotal;
        currencyFormatter=NumberFormat.getCurrencyInstance();
        currencysubtotal=currencyFormatter.format(subtotal);
        currencygst=currencyFormatter.format(((subtotal*GST)));
        currencypst=currencyFormatter.format(((subtotal*PST)));
        currencytotal=currencyFormatter.format(total);
        System.out.println("The subtotal amount is: "+currencysubtotal+" CDN.");
        System.out.println("The total GST amount is: "+currencygst+" CDN.");
        System.out.println("The total PST amount is: "+currencypst+" CDN.");
        System.out.println("The total amount is: "+currencytotal+" CDN.");
        System.exit(0);
        }
    }

}

-----------------------------------------------------------------------------------------------------------

Wednesday, January 5, 2011

Happy New Year!

Hello World!

It's a brand new year, and that entails new beginnings once again.

Here's a bit of review of some codes I've done in the past year.

Happy New Year and Welcome to 2011! ^.^

----------------------------------------------------------------------------------------------------------

import java.util.Scanner;
import java.text.NumberFormat;
public class QC_Price {

    /**
     * This program is intended to approximate the total cost of items purchased after taxes.
     * @author A. Wright
     * @version 1.0, March 2010
     */
    public static void main(String[] args) {
        Scanner kb = new Scanner(System.in);
        double PST=0.07875, GST=0.05;
        double subtotal=0,total;
        int op1, items;
        double[] prices;
        NumberFormat currencyFormatter;
       
        System.out.println("Would you like to:"
                        +"\n1.Calculate sub-total AND total costs?"
                        +"\n2.Calculate ONLY total cost?");
        op1=kb.nextInt();
        while(op1<1||op1>2){
            System.out.println("That is not a valid option.\nPlease enter a valid option:");
            System.out.println("Would you like to:"
                    +"\n1.Calculate sub-total AND total costs?"
                    +"\n2.Calculate ONLY total cost?");
            op1=kb.nextInt();
        }
        if(op1==1){
            System.out.println("Please enter number of items to be inputed:");
            items=kb.nextInt();
            while(items<0){
                System.out.println("That is not a valid number.\nPlease enter a positive value:");
                System.out.println("Please enter number of items to be inputed:");
                items=kb.nextInt();
            }
            if(items==0){
                System.out.println("No item quantity was specified.\nSystem aborting operation.");
                System.exit(0);
            }
            prices=new double[items];
            System.out.println("Please enter item prices as advertized:");
            for(int i=0;i<items;i++){
                System.out.print((i+1)+". ");
                prices[i]=kb.nextDouble();
                subtotal += prices[i];
            }
            String currencySubtotal,currencyGST,currencyPST,currencyTotal;
            currencyFormatter=NumberFormat.getCurrencyInstance();
            currencySubtotal=currencyFormatter.format(subtotal);
            currencyGST=currencyFormatter.format(((subtotal*GST)));
            currencyPST=currencyFormatter.format(((subtotal*PST)));
            System.out.println("The subtotal amount is: "+currencySubtotal+" CDN.");
            total=subtotal+(subtotal*(GST+PST));
            currencyTotal=currencyFormatter.format(total);
            System.out.println("The total GST amount is: "+currencyGST+" CDN.");
            System.out.println("The total PST amount is: "+currencyPST+" CDN.");
            System.out.println("The total amount is: "+currencyTotal+" CDN.");
            System.exit(0);
        }
       
        if(op1==2){
        System.out.println("Please enter sub-total costs:");
        subtotal=kb.nextDouble();
        while(subtotal<0){
            System.out.println("That is not a valid price.\nPlease enter a positive value:");
            System.out.println("Please enter sub-total costs:");
            subtotal=kb.nextDouble();
        }
        total=subtotal+(subtotal*(GST+PST));
        String currencysubtotal,currencygst,currencypst,currencytotal;
        currencyFormatter=NumberFormat.getCurrencyInstance();
        currencysubtotal=currencyFormatter.format(subtotal);
        currencygst=currencyFormatter.format(((subtotal*GST)));
        currencypst=currencyFormatter.format(((subtotal*PST)));
        currencytotal=currencyFormatter.format(total);
        System.out.println("The subtotal amount is: "+currencysubtotal+" CDN.");
        System.out.println("The total GST amount is: "+currencygst+" CDN.");
        System.out.println("The total PST amount is: "+currencypst+" CDN.");
        System.out.println("The total amount is: "+currencytotal+" CDN.");
        System.exit(0);
        }
    }
}

----------------------------------------------------------------------------------------------------------

/*
 * Author: A. Wright
 * Date Written: November 12, 2010
 * Purpose: To properly print out a visual of a month according to the Gregorian Calendar.
 * Assignment: 3C
 * Class: Programming 1
 * Institution: CÉGEP Vanier College
 */

import java.util.Scanner;

public class MonthCalendar {

    static Scanner kb = new Scanner(System.in); //Scanner object   
    static int yearInput, monthInput;
   
    public static int readInt()
    {
        int inputInteger;
        while(! kb.hasNextInt())
        {
            String lineInput = kb.nextLine();
            System.out.println(lineInput+" is not a valid input. Try again...");           
            System.out.println("Please enter an integer value: ");           
        }
        inputInteger = kb.nextInt();
        return inputInteger;
    }
   
    public static int readMonth()
    {
        System.out.println("Enter a month's integer value between [1-12]: ");
        monthInput = readInt();
        while(monthInput < 1 || monthInput > 12)
        {
            System.out.println(monthInput+" is not a valid integer value, try again...");
            System.out.println("Enter a month's integer value between [1-12]: ");
            monthInput = readInt();
        }
        return monthInput;
    }
       
    public static int readYear()
    {
        System.out.println("Enter a year value greater than or equal to 1582: ");
        yearInput = readInt();
        while(yearInput < 1582)
        {
            System.out.println("That is not a valid year value, try again...");
            System.out.println("Enter a year value greater than or equal to 1582: ");
            yearInput = readInt();
        }
        return yearInput;
    }
   
    public static String getMonthName(int monthValue)
    {
        String nameOfMonth = null;
       
        switch(monthValue)
        {
        case 1:
            nameOfMonth = "January";
            break;
        case 2:
            nameOfMonth = "February";
            break;
        case 3:
            nameOfMonth = "March";
            break;
        case 4:
            nameOfMonth = "April";
            break;
        case 5:
            nameOfMonth = "May";
            break;
        case 6:
            nameOfMonth = "June";
            break;
        case 7:
            nameOfMonth = "July";
            break;
        case 8:
            nameOfMonth = "August";
            break;
        case 9:
            nameOfMonth = "September";
            break;
        case 10:
            nameOfMonth = "October";
            break;
        case 11:
            nameOfMonth = "November";
            break;
        case 12:
            nameOfMonth = "December";
            break;
        }
        return nameOfMonth;
    }
   
    public static boolean isLeapYear(int year)
    {
        boolean isLeapYear = (year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0);
        return isLeapYear;
    }
   
    public static int getDaysInMonth (int month,int year)
     {
        int daysInMonth = 0;

        switch (month)
          {
             case 1: case 3: case 5: case 7: case 8: case 10: case 12: daysInMonth = 31; break;
             case 2:
                 if(isLeapYear(year))
                 {
                     daysInMonth = 29;
                 }
                 else
                     daysInMonth = 28;
                 break;
             default : daysInMonth = 30; break;

          }
           return daysInMonth;
      }
   
    public static int zeller(int month, int day, int year)
    {
       
        int d = day;
        int m = 0;
       
        switch(month)
        {
        case 1:
            m = 11;
            break;
        case 2:
            m = 12;
            break;
        case 3:
            m = 1;
            break;
        case 4:
            m = 2;
            break;
        case 5:
            m = 3;
            break;
        case 6:
            m = 4;
            break;
        case 7:
            m = 5;
            break;
        case 8:
            m = 6;
            break;
        case 9:
            m = 7;
            break;
        case 10:
            m = 8;
            break;
        case 11:
            m = 9;
            break;
        case 12:
            m = 10;
            break;
        }
        if(m == 11 || m == 12)
        {
            year -= 1;
        }
        int c = year / 100; //First 2 digits of the year
        int y = year % 100; //Last 2 digits of the year
        int z = (d + ((13 * m - 1) / 5) + y + (y / 4) + (c / 4) - (2 * c)) % 7; //Zeller's Formula
        if(z < 0)
        {
            z += 7;
        }
        return z;
    }
       
    public static void printSpace(int position)
    {
        for(int k = 0; k <= position - 1; k++)
        {
            System.out.print("     ");
        }
    }
   
    public static void printMonthAndYearCentered(String monthName, int year)
    {
        String calendarMonthYear = monthName+", "+year;
        int startingSpaces = (33/2)-(calendarMonthYear.length()/2);
        for(int k = 0; k < startingSpaces; k++)
        {
            System.out.print(" ");
        }
        System.out.println(calendarMonthYear);
    }
   
    public static void printGregorianCalendar(int month, int year)
    {
        int daysInMonth = getDaysInMonth(month, year);
        int day = 1;
        int firstDay = zeller(month, 1, year);
   
        String monthName = getMonthName(month);
   
        System.out.println();
        System.out.print("  ");
        printMonthAndYearCentered(monthName, year);
        System.out.println("\n  ---------------------------------");
        System.out.println("  Sun  Mon  Tue  Wed  Thu  Fri  Sat");
        System.out.println("  ---  ---  ---  ---  ---  ---  ---");
        printSpace(firstDay);   
        for(int w = 0 ;w <= 6 - firstDay; w++)
        {
          System.out.print("    "+ day++);
        }
        System.out.println();
        for(int y = 0; y <= 6 ; y++)
        {
           for(int x = 0; x < 7; x++)
           {
              if(day / 10 ==0)
              {
                System.out.print("    " + day++);
              }
              else
              {
                System.out.print("   " + day++);
              }
   
              if(day > daysInMonth ) break;
           }
           if(day > daysInMonth ) break;
           System.out.println();
       }
       System.out.println("\n  ---------------------------------");
    }
       
    public static void main(String[] args)
    {
        int month = readMonth();
        System.out.println("Input confirmed as valid. Continue...");
        int year = readYear();
        System.out.println("Input confirmed as valid. Retrieving Calendar archive...");
        printGregorianCalendar(month, year);       
    }   
}

-----------------------------------------------------------------------------------------------------------