Friday, January 25, 2008

Different between a = 0 and a = = 0

a = 0

a = = 0

  • value of a is coincide to zero
  • the value of a can’t change
  • value of a is equal to zero or coincide to zero
  • it will execute next instruction if a is valuable or equal to zero
  • whether next instruction will execute or end

Monday, January 21, 2008

Example Of Implication

The standard signature σ for fields consists of two binary function symbols + and ×, a unary function symbol -, and the two constants 0 and 1. Thus a structure (algebra) for this signature consists of a set of elements A together with two binary functions, a unary function, and two distinguished elements; but there is no requirement that it satisfy any of the field axioms. The rational numbers, the real numbers and the complex numbers, like any other field, can be regarded as σ-structures in an obvious way. But the ring of integers, which is not a field, is also a σ-structure in an obvious way. In fact, there is no requirement that any of the field axioms hold in a σ-structure.

A signature for ordered fields needs an additional binary relation such as algebraic structures in the usual, loose sense of the word.

The ordinary signature for set theory includes a single binary relation . A structure for this signature consists of a set of elements and an interpretation of the relation as a binary relation on these elements.

Examples of Implications

“If this lecture ends, then the sun will rise tomorrow.” True or False?

“If Tuesday is a day of the week, then I am a penguin.” True or False?

“If 1+1=6, then George passed the exam.” True or False?

“If the moon is made of green cheese, then I am richer than Bill Gates.” True or False?

Examples of Implication Wording

If John is in L.A., then he is in California

To be in California, it’s sufficient for John to be in L.A.

To be in LA, it’s necessary for John to be in California.

You will get an A if you study hard.

vs.

You will get an A only if you study hard.

Wednesday, January 16, 2008

What is problem solving?

Define problems. What are formal and informal problems?

something which is difficult to answer or to deal with or understand

How do we solve problem for computers? What are the steps?

(1) Understanding the problem
(2) Making a plan of solution

(3) Carrying out the plan
(4) Looking back i.e. verifying


Consider the following problem. "You are requited to develop a program to calculate Grade Point Average (GPA) for a student". Analyze the problem. Devise the steps (algorithm) to solve it. Code & run the program.

import javax.swing.JOptionPane;
public class machintshCGPA{
public static void main(String[] args){

//declare variables and initial values
String SInput;
String MoreGrade;
char input;
char sign;
int lenSInput;
double total=0;
double average;
boolean Grade = true;
int subjectCounter=0;

//prompt for grade input
SInput = JOptionPane.showInputDialog(null,"Please enter the grade : ","Input",JOptionPane.QUESTION_MESSAGE);


while (Grade){
subjectCounter++;
lenSInput = SInput.length();
//change the grade letter to upper case
input = SInput.charAt(0);
input = Character.toUpperCase(input);

//grade letter
switch (input){
case 'A' :
total = total + 4;
break;

case 'B' :
total = total + 3;
break;

case 'C' :
total = total + 2;
break;

case 'D' :
total = total + 1;
break;

default :
total = total + 0;
break;
}

// grade sign (+/-)

if (lenSInput == 2){
sign = SInput.charAt(1);
switch (sign){
case '-':
total = total - 0.25;
break;

case '+':
total = total + 0.5;
break;

default:
total = total + 0;
}
}

else
total = total + 0;

//ask for more grades
MoreGrade = JOptionPane.showInputDialog(null,"Have more grade?\n[1 for Yes, 2 for No]\nGrades counted:"+subjectCounter,"Input",JOptionPane.QUESTION_MESSAGE);
if (Integer.parseInt(MoreGrade)==2){
Grade = false;
}

else
SInput = JOptionPane.showInputDialog(null,"Please enter the grade : ","Input",JOptionPane.QUESTION_MESSAGE);

}

//calculation
average = total / subjectCounter;


JOptionPane.showMessageDialog(null,"The average grade = "+average,"Average Grade",JOptionPane.INFORMATION_MESSAGE);
}
}

Output



































Why learn Discrete Structures?

What is Discrete?

The word discrete comes from the 15th Century latin word discretus which means separate from each other or unconnected.

What is Structures?

Something made up of a number of parts that are held or put together in a particular way and hierarchical social structure. The way in which parts are arranged or put together to form a whole makeup triangular in structure. The interrelation or arrangement of parts in a complex entity, political structure, plot structure. Something constructed, such as a building.


So, what is Discrete Structures (DS)?

These are the abstract mathematical structures used to represent discrete objects and relationships between those objects.

Why is DS important?

These structures form the conceptual basis for many of the data structures that we use as programmers. To use DS as abstract models for use in solving problems and developing algorithms.


How do we apply DS?

  • Functions, relations, and sets,

  • Basic logic,

  • Proof techniques,

  • Basics of counting,

  • Graphs and trees,

  • Discrete probability

Assignment 2

Consider the following problem. Jaskom carries out a survey of Computer Science Students and the result shows the following:
a- For question "Do you have computers?", 221 answered "Yes".,
b- For question "Do you have Java programming books?", 159 answered "Yes", and
c- For question "Do you have computers and Java programming books?", 87 answered "Yes".

Do an analysis of these data and solve the following problems. Among the students of Computer Science who have at least computers and Java programming books, find the percentage (%) of students who :

Have computer = C
Have Java Programming book = J
Have Both = B
Total = T

B = 87


C + 87 = 221
C = 221 - 87
C = 134

J + 87 = 159
J = 159 - 87
J = 72

C + J + 87 = T
T = 134 + 72 + 87
T = 293


a) have at least one computers and programming books

(C + J)/293 *100
= (134 + 72)
/293 *100
= 70.31%


b) have only computers

C/293 *100
= 134
/293 *100
= 45.73%


c) have only programming books

J/293 *100
= 72
/293 *100
= 24.57%


d) have both computers and programming books

B
/293 *100
= 87
/293 *100
= 29.69%



Sunday, January 6, 2008

Group Members Info

NAME : AHMAD NASIRUDDIN BIN RADZALY@GHAZALI (UK14164)
ADDRESS : 196,TAMAN MURNI PERMAI,TOK JEMBAL 21300 K.TERENGGANU
E-MAIL : nash_say88@yahoo.com
PHONE NO. : 0179789643
MOTTO : USAHA TANGGA KEJAYAAN

NAME : AHMAD SYAHMI BIN DUNYA (UK13749)
TEMPORARY ADDRESS : RUMAH 7B-1 ASRAMA JEMBAL INN,UMT 21030 K.TERENGGANU
E-MAIL : syahmi87@yahoo.com
PHONE NO. : 0199138748
MOTTO : -

NAME : MOHD MARWAN BIN ZAHARI (UK13253)
TEMPORARY ADDRESS : RUMAH 8A-4 ASRAMA JEMBAL INN,UMT 21030 K.TERENGGANU
E-MAIL : marwanranggi_paritboy@yahoo.com
PHONE NO. : 0125926568
MOTTO : SEPAKAT MEMBAWA BERKAT

NAME :WAN MOHD AZHAN BIN WAN GHAZALI (UK14074)
TEMPORARY ADDRESS : TM-4B2-1,ASRAMA TAMAN MAIDAM,UMT 21300 K.TERENGGANU
E-MAIL : azhan_ghazali@yahoo.com
PHONE NO. : 0199347059
MOTTO : -