JAVA Hands on Lab (2)

Read data from a file.
Object Oriented Software Engineering - Java
Khalilur Rahman

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package courseregistrationsystem2;

import java.io.BufferedReader;
import java.io.FileReader;

/**
 *
 * @author khal
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    static Course[] allCourses;
    public static void main(String[] args) {
        // TODO code application logic here
        allCourses = new Course[50];
        readSourceFile("StudentDataInput.txt");
    }
    public static void readSourceFile(String fileName){
        String code, venue, title, instructor;
        try {
            FileReader fileReader = new FileReader(fileName);
            BufferedReader in = new BufferedReader(fileReader);
            int numberOfCourse = Integer.parseInt(in.readLine());
            for (int i = 0; i < numberOfCourse; i++){
                if ((code = in.readLine())== null) break;
                if ((venue = in.readLine())== null) break;
                if ((title = in.readLine())== null) break;
                if ((instructor = in.readLine())== null) break;
                createCourse(i, code, venue, title, instructor);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
    public static void createCourse(int index, String code, String venue,
            String title, String instructor){

        allCourses[index]= new Course();
        allCourses[index].code = code;
        allCourses[index].venue = venue;
        allCourses[index].title = title;
        allCourses[index].instructor = instructor;

        System.out.println(allCourses[index].code);
        System.out.println(allCourses[index].venue);
        System.out.println(allCourses[index].title);
        System.out.println(allCourses[index].instructor);
    }
}

JAVA Hands on Lab (1)

Object oriented Software Engineering - Java
Khalilur Rahman

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package courseregistration;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

/**
 *
 * @author khal
 */
public class courseRegistration {

    /**
     * @param args the command line arguments
     */
    static Course[] allCourses;
    public static void main(String[] args) {
        // TODO code application logic here
        allCourses = new Course[50];

        allCourses[0] = new Course();
        allCourses[0].code =  "CI6201";
        allCourses[0].title =  "Professional Seminar";
        allCourses[0].venue =  "LT2";
        allCourses[0].instructor =  "Paul Wu";
        allCourses[0].academicUnit = 3;

        allCourses[1] = new Course();
        allCourses[1].code =  "CI6202";
        allCourses[1].title =  "Information Architecture";
        allCourses[1].venue =  "LT3";
        allCourses[1].instructor =  "Chris Khoo";
        allCourses[1].academicUnit = 3;

        allCourses[2] = new Course();
        allCourses[2].code =  "CI6203";
        allCourses[2].title =  "Software Engineering";
        allCourses[2].venue =  "LT5";
        allCourses[2].instructor =  "W K Ng";
        allCourses[2].academicUnit = 3;

        displayCourse();
        pickCourse();
        pickCourseCode();
    }
    public static void displayCourse(){
        try {
            for (int i = 0; i < 50; i++ ){
                if (allCourses[i]==null) break;
                System.out.println(allCourses[i].code);
                System.out.println(allCourses[i].title);
                System.out.println(allCourses[i].instructor);
                System.out.println(allCourses[i].venue);
                System.out.println(allCourses[i].academicUnit);
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }

    }
    public static void pickCourse(){
        try {
            System.out.print("Enter the course code: ");
            BufferedReader in = new BufferedReader(
                    new InputStreamReader(System.in));
            int i = Integer.parseInt(in.readLine());
                System.out.println(allCourses[i].code);
                System.out.println(allCourses[i].title);
                System.out.println(allCourses[i].instructor);
                System.out.println(allCourses[i].venue);
                System.out.println(allCourses[i].academicUnit);
        } catch (Exception e) {
        }
    }
    public static void pickCourseCode(){
        try {
            System.out.print("Enter course ID: ");
            BufferedReader in = new BufferedReader(
                    new InputStreamReader(System.in));
            String code = in.readLine();
            for (int i =0; i < 50; i++){
                if (allCourses[i]==null) break;
                if (allCourses[i].code.equals(code)){
                    System.out.println(allCourses[i].code);
                    System.out.println(allCourses[i].title);
                    System.out.println(allCourses[i].instructor);
                    System.out.println(allCourses[i].venue);
                    System.out.println(allCourses[i].academicUnit);
                }
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }

Algorithm?

THe Father of AlgorithmThe word “algorithm”? is quite interesting; at first glance it may look as though someone intended to write “logarithm” but jumble up the first four letters. The word did not appear in Webster’s New World Dictionary as late as 1975; we found only the older form “algorism” with this ancient meaning, the process of doing arithmetic using Arabic numerals. During the Middle Ages, abacists computed on the abacus and algorists computed by algorism. By the time of the Renaissance, the origin of this word was in doubt, and early linguists attempted to guess at its derivation by making combinations like algiros [painful]+arithmos [number]; others said no, the word comes from “King Algor of Castile.” Finally, historians of mathematics found the true origin of the word algorism: It comes from the name of a famous Persian textbook author, Abu Abd Allah Muhammad ibn Musa al-Khawarizmi — literally, “Father of Abdullah, Mohammed, son of Moses, native of Khawarizm.” The Aral sea in Central Asia was once known as Lake Khawarizm, and the Khawarizm region is located in the Amu River basin just south of that sea. Al-Khawarizmi wrote the celebrated Arabic text Kitab al-jabr wa’l-muqabala (“Rules of restoring and equating”); another word, “algebra,” stems from the title of that book, which was a systematic study of the solution of linear and quadratic equations. [For notes on al-Khwarizmi's life and work, see H. Zemanek, Lecture in  Computer Science 122 (1981, 1-81.]

Gradually the form and meaning of algorism became corrupted; as explained by the Oxford English Dictionary, the word “passed through many pseudo-etymological perversions, including a recent algorithm,  in which it is learnedly confused” with Greek root of  the word arithmetic. This change from “algorism” to “algorithm” is not hard to  understand in view of the fact that people had forgotten the original derivation of the word. An early German mathematical dictionary, Vollstandiges mathematisches Lexicon: “(Leipzig: 1774), gave the following definition for the word Algorithmus: “Under this designation are combined the notions of the four types of arithmetic calculations, namely addition, multiplication, substraction, and division.” The Latin phrase algorithmus infinitesimalis was at that time used to denote “ways of calculation with infinitely small quantities, as invented by Leibniz.

By 1950, the word algorithm was most frequently associated with Euclid’s algorithm, a process for finding the greatest common divisor of two numbers that appears in Euclid’s Elements (Book 7, Propositions 1 and 2).

[Donald Knuth, The Art of Computer Programming, volume 1, 2007]

Interview with Donald Knuth

Andrew Binstock and Donald Knuth converse on the success of open source, the problem with multicore architecture, the disappointing lack of interest in literate programming, the menace of reusable code, and that urban legend about winning a programming contest with a single compilation.

read more

Microsoft Releases Robotics Developer Studio 2008 CTP

by Michael Desmond
09 April 2008

MSDN Logo Microsoft today released the first community technology preview (CTP) of Robotics Developer Studio 2008 at the RoboBusiness conference in Pittsburgh. The product is the third version of the robotics programming platform, which previously had been called the Microsoft Robotics Studio.

Microsoft Robotics Developer Studio 2008 (RDS 08) significantly improves runtime performance, from 150 percent to 300 percent, according to Microsoft General Manager of the Robotics Group Tandy Trower. “It’s not the monolithic, single-threaded model that people have normally used for robots. Instead this is a more asynchronous, distributed approach to programming,” Trower said.

Trower said RDS 08 will enable developers to write code and routines that rely on asynchronous message passing, providing for a more distributed runtime environment and expanding the potential for future robots to process and act on large volumes of information. According to a Microsoft release, RDS 08 adds support for distributed language integrated queries (LINQ), intended to enable “advanced filtering and inline processing of sensor data at the source.”

According to Trower, the distributed application architecture will make it easier for robotic applications to access processing from remote sources, enabling a simple machine to act on complex processing done on a corporate server or in the cloud.

“You can have cooperative robotic interaction, because the robots can easily share information among each other,” Trower said.

The RDS 08 CTP also provides improved sensor interaction, enabling sensors to send granular state change information to the processor, rather than requiring code that constantly checks sensor status.

Microsoft Robotics Studio was launched in 2006 to give developers a way to write high-level robotics applications without having to dive down into the minutiae of hundreds of different sensor and motor interfaces.

Ultimately, Trower said, the tools and techniques developers in the Robotics group could very well end up in mainstream development products at Microsoft.

“You will see that this year the core pieces — the CCR, which is our concurrency coordination runtime and our DSS services, which is its companion that provides the concurrency model across the distributed network — these pieces we actually will separate out and offer independently as well as in the toolkit, so that people who are interested in using this for [other] applications will be able to do that,” Trower said.

“You will also see them positioned as part of the development tools family outside of the robotics area by our marketing team in our developer tools marketing group.”
Michael Desmond, former editor at large of Redmond magazine, is the editor in chief of Redmond Developer News magazine. He has served as senior editor of news at PC World and executive editor at Multimedia World magazine, and has written for dozens of publications and Web sites. Desmond has also written four computing books, including Microsoft Office 2003 in 10 Simple Steps or Less.




IKIBLOGKU is Digg proof thanks to caching by WP Super Cache!