TA5004 - COMPUTER PROGRAMMING (MSc-IT)

 

 

ASSIGNMENT #: ___

 

 

METRIC NUMBER : ______________

 

NAME : ________________________________

 

 

TOTAL QUESTIONS ANSWERED: ___

 

 

SIGNATURE : __________________ DATE : ______________

 

TA5044: Rough Schedule

Date

Lecture

Topic

Quiz

Assignment

____

1

Introduction To Computing

 

 

____

2

Introduction To Programming

 

 

____

3

Decisions

1

1

____

4

Iterations

 

 

____

5

OOP: Objects (Using Classes)

2

2

____

6

OOP: User-defined Classes

 

 

____

7

OOP: Inheritance and Polymorphism

3

 

____

8

Arrays

 

3

____

9

Data Structures: Lists

4

 

____

10

Data Structures: Stack and Queue

 

 

____

11

Algorithm Analysis: Sorting and Searching

5

4

____

12

Programming Languages I

 

 

____

13

Programming Languages II

6

5

____

14

Applets, HTML and other issues

 

 


Last updated on May 30, 1999

 

 

 

 

TA5004 : Assessment


Marks dissection:
Quiz: 5 X 3% = 15%
Assignments: 5 X 5% = 25%
Mid semester exam: = 20%
Final exam: = 40%
Total: 100%


Notes in tests:

Tests (both) will be open-note (printed on a page of A4 paper). You should hand-in the note to be taken in the test one week before the test.

Quiz and Assignment:

Every approximately 2 weeks (see Rough Schedule), you'll take a quiz and have to hand-in an assignment. If you solved your assignment questions very well (on your own) you don't have to worry about taking the quiz since the quiz questions are based on the assignment. The quizzes and assignments cover the topics discussed in the previous 2 lectures. Example -- quiz 1 (3rd week) will cover the topics for lessons in week 1 and 2.

Make-up quiz?

There will be no make-up quiz -- if you missed one, you will get zero mark for that particular quiz. However, at the end of the semester, there will be an extra quiz. Your total quiz mark will be the best five from all six.


<<Back.
-- updated: 13-Jun-99 19:29 --

The "Hello World" Applet

By following the steps on this page, you can create and use an applet.

Create a Java Source File

Create a file named HelloWorld.java with the Java code shown here:

import java.applet.Applet;
import java.awt.Graphics;
 
public class HelloWorld extends Applet {
    public void paint(Graphics g) {
        g.drawString("Hello world!", 50, 25);
    }
}

Compile the Source File

Compile the source file using the Java compiler.

If the compilation succeeds, the compiler creates a file named HelloWorld.class in the same directory (folder) as the Java source file (HelloWorld.java). This class file contains Java bytecodes.

If the compilation fails, make sure you typed in and named the program exactly as shown above.

Create an HTML File that Includes the Applet

Using a text editor, create a file named Hello.html in the same directory that contains HelloWorld.class. This HTML file should contain the following text:

<HTML>
<HEAD>
<TITLE> A Simple Program </TITLE>
</HEAD>
<BODY>
 
Here is the output of my program:
<APPLET CODE="HelloWorld.class" WIDTH=400 HEIGHT=300>
</APPLET>
</BODY>
</HTML>

Run the Applet

To run the applet, you need to load the HTML file into an application that can run Java applets. This application might be a Java-compatible browser or another Java applet viewing program, such as the Applet Viewer provided in the JDK. To load the HTML file, you usually need to tell the application the URL of the HTML file you've created. For example, you might enter something like the following into a browser's URL or Location field:

d:\javaccj\Hello.html

Once you've successfully completed these steps, you should see something like this in the browser window:

 

 

TA5004 - COMPUTER PROGRAMMING (MSc-IT)

ASSIGNMENT 1 QUESTIONS : INTRODUCTION TO COMPUTING AND PROGRAMING


There are 5 questions for this assignment.
Email your answer for question 1.
For questions 2 to 5, hand in the hard-copy.
For questions 4 and 5, hand in:

  1. The pseudocode (printed in Times New Roman font)
  2. The source code (Java program) (printed in Courier New or Courier font)
  3. 2 sample output. (printed in Courier New or Courier font)

  1. Please send me an e-mail introducing yourself. You should write:
    1. Your name:
    2. Your home address and telephone number:
    3. Your office address and telephone number:
    4. A short paragraph telling why you are interested to further your study and why do you choose this IT field.
    5. A nickname (not more than 7 letters) -- for me to display your coursework on the WWW.
    6. A paragraph: other things -- you can write anything here: hobbies, family, works, etc.

  1. Write explanations how to achieve these tasks in Windows 95. (questions a to d, using mouse. The rest, using keyboard)
    1. Copying files from your hard disk to the disket.
    2. Deleting a file that resides on your desktop.
    3. Making a shortcut to the Notepad program on the desktop.
    4. Copying a section of text in Notepad -- into the same document.
    5. Moving the cursor to the end of line in Notepad.
    6. Moving the cursor to the beginning of line in Notepad.
    7. Moving the cursor to the end of document in Notepad.
    8. Moving the cursor to the beginning of document in Notepad.
    9. Advancing the cursor one word in Notepad.

  1. Write explanations on how to achieve these tasks in DOS. (assume you are in the root directory of C: drive.)
    1. Make a new directory with the name "myjava".
    2. Change your current directory to the newly created "myjava" directory.
    3. Copy the file "Hello.java" from d:\jdk1.2\bin into your current directory.
    4. Look at the content of the "Hello.java" file.
    5. Compile the "Hello.java" file.
    6. Run the "Hello" program.

  1. Make a program that will cut a portion of input text. The user can key-in the text and the number of characters to cut.
    Sample Run I:
5.           Type in the string: >prasyarat
6.           How many first characters to cut?: >3
7.            
The original, the excerpt and the remaining string: prasyarat, pra, syarat


Sample Run II:

Type in the string: >biadab
How many first characters to cut?: >2
 
The original, the excerpt and the remaining string: biadab, bi, adab

For some hints, see: a demo of substring().


  1. Write a program to calculate the circumference and area of a circle from a user's entry of its radius. Show the circle's radius, circumference and area.
    For some hints to answer this question, see answer for assignment1, last semester. (But in those sample answers, we use Console.in.readDouble() -- you should use easy.readDouble() instead.)

Due date: 13-June-1999



<<Back to assessment page.

Updated : 06-Jun-99 19:06

TA5004 - COMPUTER PROGRAMMING (MSc-IT)

ASSIGNMENT 2 QUESTIONS : Decisions and Loops


There are 3 questions for this assignment. You must answer just 2 questions: question 1 and (question 2 or question 3). Hand in:

  1. The source code (Java program) (printed in Courier New or Courier font)
  2. 4 sample output for each question you answered. (printed in Courier New or Courier font)

  1. (2 marks) Make a program that can produce a "kata-berganda" for Malay words that starts with letter k, p, s or t.
    Sample Run:
2.    Type in the string: >kipas
The double: kipas-mengipas

The following samples in the table should make things clear.

Input

Output

tambah

tambah-menambah

sapu

sapu-menyapu

kata

kata-mengata

picit

picit-memicit

rosak

Sorry...word did not start with t/s/k/p

 


  1. (3 marks) UUM is conducting a survey to identify suitable candidate to participate in Enterpreneurship Training Program. Based on the questions asked, a suitable candidate can be determined.

Make a program that ask for some background data of a candidate, and determine whether or not he/she is qualified.

Sample interaction for input:

 

1. Age?                                        > 25

2. Business experience (years)?                > 2

3. Own a registered company (y/n)?             > y

4. Is your main job doing business (y/n)?      > y

5. Education (1:primary school, 2:LCE, 3:MCE)? > 2

6. Business progress level (1/2/3/4/5)?        > 3

7. Passed the pre-interview exam (y/n)?        > y

To qualify, a candidate has to satisfy either one of these conditions:

 

Condition

Question #

OR

Age: between 17 and 50 years old, inclusive AND
Involved in business for at least 1 year AND
Own a registered company

1
2
3

OR

Age: between 17 and 50 years old, inclusive AND
Main job is doing business AND
Minimum education is primary school AND
Passed the pre-interview exam AND
Business progress level 2 or 3 or 4.

1
4
5
7
6

OR

Age: between 17 and 50 years old, inclusive AND
Main job is doing business AND
Minimum education: passed the LCE AND
Business progress level 2 or 3 or 4.

1
4
5
6

OR

Age: between 17 and 50 years old, inclusive AND
Minimum education: passed the MCE AND
Passed the pre-interview exam AND

1
5
7


(Do not try to care about what is "business progress level 2 or 3 or 4" means. Just program it.)

Output is just one line: whether the candidate is qualified or not.

Note:

    1. There are so many possibilities of input set. So please make sure that your program can give correct output for any (valid) set of input.
    2. This problem involves complex conditions. Make sure your program is readable. You can break the conditions into several small sub-conditions.
    3. Use loops to guard against invalid input for questions 3 - 7. Example: Education other than 1/2/3 is invalid. Answer to y/n questions should take only y or n, no other than that.

  1. (3 marks) Make a program that can analyze a string input by the user. It should display:

                                 i.            Total number of vowels (a/e/i/o/u) in the string.

                               ii.            Total number of words in the string. Assume words are separated by these separators: either a space, a comma (,), a fullstop(.) or an exclamation mark(!).

Note:

                               c.            For simplicity, assume that the string does not start with a separator. It starts with a letter.

                              d.            Your program must be able to handle strings that:

      1. have a single letter word such as the word "a".
      2. end with a separator, such as "I am strong enough!".
      3. have adjacent separators, such as the comma and the space in "one, two".

Sample input and output:

Input string

Output

Decisions and Loops

Vowels: 7 Words:3

Truth is stranger than fiction, but it is because fiction is obliged to stick to possibilities. Truth isn't.

Vowels: 33 Words:18

Err... you're confused...!

Vowels: 7 Words:3

Due date: 4/July/1999 -- extended to 7/July/1999



<<Back to assessment page.

Updated : 29-Jun-99 15:26

TA5004 - COMPUTER PROGRAMMING (MSc-IT)

ASSIGNMENT 3 QUESTIONS : OOP


There are 2 questions for this assignment. For each question, hand in:

  1. The source code (Java program) (printed in Courier New or Courier font)
  2. 2 sample output. (printed in Courier New or Courier font)

  1. For topic: (OOP: Objects -- Using Classes)
    Make a Hangman game.
    Here is a sample pseudocode that you can use as a guide.
2.         PLAYER 1 -- input the phrase and letters to hide
3.         input the phrase
4.     
5.         do 
6.             read letter to hide
7.             hide it (replace the letter with the '-' )
8.         while player 2 does not type '.'
9.     
10.     clear screen: (print 25 empty lines)
11. 
12.     PLAYER 2 -- guessing
13.     do 
14.         input a letter to guess
15.         if hit: 
16.           replace the '-' with the letter 
17.         else:
18.           increment and print out the number of misses so far
19. 
20.         check for settled: is there any '-' left?
21. 
22.     while puzzle is not settled and number of guess not exceeded 10
23. 
24.     LAST OUTPUT
25.     if settled
26.       print "congratulations! " + number of missed
27.     else
       print "sorry... you failed."


Sample interaction:

***PLAYER 1***:
Input a phrase > kebersihan jiwa
Phrase input is: kebersihan jiwa
Letter to hide? (. to end)> e
Phrase now: k-b-rsihan jiwa
Letter to hide? (. to end)> i
Phrase now: k-b-rs-han j-wa
Letter to hide? (. to end)> a
Phrase now: k-b-rs-h-n j-w-
Letter to hide? (. to end)> r
Phrase now: k-b--s-h-n j-w-
Letter to hide? (. to end)> s
Phrase now: k-b----h-n j-w-
Letter to hide? (. to end)> 

When player 1 type fullstop, the screen clears (by scrolling up) and display this at the bottom:

***PLAYER 2***:
Phrase now: k-b----h-n j-w-
Letter to guess? >

Now player 2 start guessing by typing a letter at the prompt. This is continued until the phrase is completed.

***PLAYER 2***:
Phrase now: k-b----h-n j-w-
Letter to guess? > a
Phrase now: k-b----han j-wa
Letter to guess? > o
No --> 1 misses.
Phrase now: k-b----han j-wa
Letter to guess? > u
No --> 2 misses.
Phrase now: k-b----han j-wa
Letter to guess? > e
Phrase now: kebe---han j-wa
Letter to guess? > r
Phrase now: keber--han j-wa
Letter to guess? > i
Phrase now: keber-ihan jiwa
Letter to guess? > t
No --> 3 misses.
Phrase now: keber-ihan jiwa
Letter to guess? > s
Phrase now: kebersihan jiwa
Congratulations! 3 misses.

  1. For topic: (OOP II: User-defined Classes) Use the TestScore class (discussed in lecture) to do this question. (You don't have to change anything on the TestScore class. Use it as it is.) Make a program that keep asking for the following information until the user typed in "zzz" as the students' name:
    1. The student's name.
    2. His/her score for section 1.
    3. His/her score for section 2.
    4. His/her score for section 3.
    5. Create a new object using this information.

Print out this information:

    1. The name of student that get the highest total score.
    2. The name of student that get the highest section 1 score.
    3. The name of student that get the highest section 2 score.
    4. The name of student that get the highest section 3 score.
    5. The average score for section 1.
    6. The average score for section 2.
    7. The average score for section 3.

Sample algorithm:

 
start program
 
ask for name
 
while name not equal to "zzz"
  ask for scores for sect 1, 2 and 3
 
  create a new object, ex:
   TestScore st = new TestScore(name, sect1, sect2, sect3);
  get the total number of students, ex:
   numOfStudents = st.getStudentNumber(); // or numOfStudents++;
 
   if highest score sect1 < sect1 score for the current student then
     let highest score sect1 be the sect1 score for current student
     let name of student whose sect1 is highest be the current name.
 
   -- the same (if) goes with sect2, 3 and total score
 
   sum the sect1 score: use getScore(1)
   -- the same goes with sect2 and 3
 
   ask for next name
end of while
    
calculate average
 
print all output
 
end program

Due date: 8/Aug/1999


Updated : 20-Jul-99 11:42

TA5004 - COMPUTER PROGRAMMING (MSc-IT)

ASSIGNMENT 4 QUESTIONS : Arrays


There are 2 questions for this assignment, but you are required to answer only 1 question. Hand-in: :

  1. The source code (Java program) (printed in Courier New or Courier font). You must hand in the source as hard-copy (as usual) and soft-copy (attach the .java file with your email)
  2. 2 sample output. (printed in Courier New or Courier font)

Choose only 1 from these 2 questions:


  1. Make a program (use array) that can determine the winner from a circle of 10 players. The input to the problem is i) where to start counting and ii) how many count (of players) to make to determine the next player to go out. The last player that stay is the winner. You can determine how your output will be, but here is an example:

Sample run and output:

 
> java FindLoopWinner 4 3
start counting from 4,
1 2 3 4 5 6 7 8 9 10
6 is out, start counting from 7,
1 2 3 4 5 7 8 9 10
9 is out, start counting from 10,
1 2 3 4 5 7 8 10
2 is out, start counting from 3,
1 3 4 5 7 8 10
5 is out, start counting from 7,
1 3 4 7 8 10
10 is out, start counting from 1,
1 3 4 7 8
4 is out, start counting from 7,
1 3 7 8
1 is out, start counting from 3,
3 7 8
8 is out, start counting from 3,
3 7
3 is out, 7 is the winner!

  1. Make a "Mastermind" game. Human vs. computer. The computer generate the series (randomly), and the user guess. This is an open-ended question. It's all yours. If you have never heard what is Mastermind before, try to play it first (no, your program don't have to be like that one, make a much simpler version). You decide how the interactions would be, and how complex the game would be. Obviously your program will only use the text-based user interface (like before). Use your creativity to make it more interesting (and more challenging?).

Due date: 29/Aug/1999.


Updated : 09-Aug-99 14:28

TA5004 - COMPUTER PROGRAMMING (MSc-IT)

ASSIGNMENT 5 QUESTIONS : Programming Languages


There are only 1 question for this assignment.


  1. Write an essay with the title: "Java: Readability, Writability and Efficiency"

Specification of document:


Due date: 19-Sep-99


Updated : 01-Sep-99 11:51