Wednesday, January 16, 2008

Answers for Question C

Haha... at last, my turn to give answer......

Actually not hard one... just follow the steps :

STEP 1 : Analyze the Problem

This is a "find" problem.

Unknowns - GPA
Data - course grade, course credit hours,
Conditions - GPA must be in between 0 and 4
Credit hours must not be 0

STEP 2 : Devise a solution plan

As Prof. Yazid said, we need to know each word well. Therefore, we need to know the definition on some terms.

To make it simple, I don't want to copy all words from wikipedia lah, I use my own words ah... (got a bit cacat la... I sure you all oso dun want to see all the words from wikipedia rite? )

GPA = GRADE POINT AVERAGE = AVERAGE OF THE SUM OF GRADE POINTS = (SUM OF GRADE POINTS) / SUM OF CREDIT HOURS

GRADE POINTS = GRADE * CREDIT HOUR OF THE GRADE

OK, enough of definition. Now we need a sub-conclusion on this part, which is :

To calculate GPA, we need :
1) SUM OF credit hours
2) SUM OF grade point

and to find grade point we need :
1) grade
2) credit hour OF the grade

Step 3 : Code & run the program

WHOA!!!!!!!! This is the part where I will be clapping my hands XD...
Its JAVA PROGRAMMING TIME!!!!!!

Erm, should I paste the coding here or what?
Like this la, I paste it here first, then if you all feel not suitable, we open a webFolder account k, then we paste there.

=== CODING STARTS ===

import javax.swing.JOptionPane ;
public class gpaCalculator {

public static void main ( String[] args ) {

String tempParser ;
int subjectCount, tempUSE ;
double totalGP , totalCHour, tempGP, tempCHour, GPA ;
totalGP = 0 ;
totalCHour = 0 ;

tempParser = JOptionPane.showInputDialog("Please enter the total number of subjects : ") ;
subjectCount = Integer.parseInt(tempParser) ;

for ( int x = 0 ; x < subjectCount ; x ++ ) {

tempParser = JOptionPane.showInputDialog("Please enter the grade awarded for subject " + (x+1) + " according to the menu below.\n(1) A\n(2) A-\n(3) B+\n(4) B\n(5) B-\n(6) C+\n(7) C\n(8) C-\n(9) D+\n(10) D\n(11) D-\n(12) Fail") ;
tempUSE = Integer.parseInt(tempParser) ;
tempGP = findPoint(tempUSE) ;

tempParser = JOptionPane.showInputDialog("Please enter the credit hours associaated to subject " + (x+1) + ".") ;
tempUSE = Integer.parseInt(tempParser) ;
tempCHour = tempUSE ;
totalCHour = totalCHour + tempCHour ;

totalGP = totalGP + (tempGP * tempCHour) ;

}

GPA = totalGP / totalCHour ;

JOptionPane.showMessageDialog(null,"Your GPA is " + GPA + "." ) ;
System.exit(0) ;

}

public static double findPoint(int x){

if (x == 1)
return 4.0 ;
if (x == 2)
return 3.7 ;
if (x == 3)
return 3.3 ;
if (x == 4)
return 3.0 ;
if (x == 5)
return 2.7 ;
if (x == 6)
return 2.3 ;
if (x == 7)
return 2.0 ;
if (x == 8)
return 1.7 ;
if (x == 9)
return 1.3 ;
if (x == 10)
return 1.0 ;
if (x == 11)
return 0.7 ;
if (x == 12)
return 0.0 ;
else
return 0.0 ;

}

}

=== CODING ENDS ===

So? Just put whatever data required and then the calculator calculates for you. Easy right?

So?? Chaoz=== Cheerz!

Discussion --What is problem solving?--

Questions:
a- Define problems. What are formal and informal problems? Give examples of them.
b- How do we solve problem for computers? What are the steps?
c- Consider the following problem.
"You are requited to develop a program to calculate Grade Point Average (GPA) for a student"
c1- Analyze the problem.
c2- Devise the steps (algorithm) to solve it.
c3- Code & run the program.


Solutions:
a-
problem (from Concise Oxford Dictionary)
·-noun.
1- an unwelcome or harmful matter needing to be dealt with and overcome. Ø a thing that is difficult to achieve.
2 Physics & Mathematics an inquiry starting from given conditions to investigate or demonstrate something.

Formal problem is
where the problem and the possible solutions are stated in a precise way, and so is the notion of correctness, stating whether a solution solves a problem. For example, equations, expressions and algorithms.

Informal problem is where the
cannot be solve by machine because it is abstract. For example, feeling, emotion and spirit.



b-

We solve the problems for computers by using some kind of approaches to avoid dealing with a extremely large number of possibilities.

The steps of solving problems:

1. Understanding the problem

2. Making a plan of solution

3. Carrying out the plan

4. Looking back i.e. verifying



----refreshing-----

Discussion --Why learn Discrete Structures?--

Questions:
Define the following terms:
- What is Discrete? (lookup in a dictionary)
- What is Structures?
- So, what is Discrete Structures (DS)?
- Why is DS important?
- How do we apply DS?
- Read in History of DS (refer to Links)



Solutions:

1.

Collins COBUILD Advanced Learner's English Dictionary



discrete
Discrete ideas or things are separate and distinct from each other. (FORMAL)
...instruction manuals that break down jobs into scores of discrete steps.
= separate

Longman Dictionary of Contemporary English



discrete
di·screte /dɪˈskriːt/ adj
–adjective

1.

apart or detached from others; separate; distinct: six discrete parts.

2.

consisting of or characterized by distinct or individual parts; discontinuous.

3.

Mathematics.

a.

(of a topology or topological space) having the property that every subset is an open set.

b.

defined only for an isolated set of points: a discrete variable.

c.

using only arithmetic and algebra; not involving calculus: discrete methods.

Oxford Advanced Learner's Dictionary



discrete

ect(formal or technical) independent of other things of the same type
Synonym: SEPARATE
The organisms can be divided into discrete categories.



2.

Essential English Dictionary



structure
-noun

1
. a thing constructed; a complex entity constructed of many parts
2
. the manner of construction of something and the arrangement of its parts
3
. the complex composition of knowledge as elements and their combinations
4
. a particular complex anatomical part
5
. the people in a society considered as a system organized by a characteristic pattern of relationships

-verb
give a structure to

WordNet Online



structure
-Noun

· structure, construction (a thing constructed; a complex entity constructed of many parts)

"the structure consisted of a series of arches"; "she wore her hair in an amazing construction of whirls and ribbons"

· structure (the manner of construction of something and the arrangement of its parts)

"artists must study the structure of the human body"; "the structure of the benzene molecule"

· structure (the complex composition of knowledge as elements and their combinations)

"his lectures have no structure"

· structure, anatomical structure, complex body part, bodily structure, body structure (a particular complex anatomical part of a living thing)

"he has good bone structure"

· social organization, social organisation, social structure, social system, structure (the people in a society considered as a system organized by a characteristic pattern of relationships)

"the social organization of England and America is very different"; "sociologists have studied the changing structure of the family"

-Verb

· structure (give a structure to)

"I need to structure my days"

Oxford Advanced Learner's Dictionary



structure
-noun
-the way in which the parts of sth are connected together, arranged or organized; a particular arrangement of parts: the structure of the building / human body
changes in the social and economic structure of society the grammatical structures of a language a career / salary / tax structure
- a thing that is made of several parts, especially a building: a stone / brick / wooden structure
- the state of being well organized or planned with all the parts linked together; a careful plan: Your essay needs (a) structure.


3.

Discrete structures are sets of distinct or unconnected elements. Discrete mathematics is mathematics that deals with discrete objects. Discrete objects are those which are separated from (not connected to/distinct from) each other. Integers (aka whole numbers), rational numbers (ones that can be expressed as the quotient of two integers), automobiles, houses, people etc. are all discrete objects. On the other hand real numbers which include irrational as well as rational numbers are not discrete. As you know between any two different real numbers there is another real number different from either of them. So they are packed without any gaps and can not be separated from their immediate neighbors. In that sense they are not discrete. We will be concerned with objects such as integers, propositions, sets, relations and functions, which are all discrete.



4.
Related to the problem of correctness of computer programs, there is the well known "Halting Problem". This problem, if put into the context of program correctness, asks whether or not a given computer program stops on a given input after a finite amount of time. This problem is known to be unsolvable by computers. Thus we need some kind of formal approaches here to avoid dealing with a extremely large number (if not infinite) of possibilities.

Discrete mathematics is the foundation for the formal approaches. It discusses languages used in mathematical reasoning, basic concepts, and their properties and relationships among them.

Discrete mathematics is also concerned with techniques to solve certain types of problems such as how to count or enumerate quantities. The kind of counting problems includes:

a) How many routes exist from point A to point B in a computer network ?
b) How much execution time is required to sort a list of integers in increasing order ?
c) What is the probability of winning a lottery ?
d) What is the shortest path from point A to point B in a computer network ?


5.

We apply discrete structures to the computer science includes:
  • Functions, relations, and sets,
  • Basic logic,
  • Proof techniques,
  • Basics of counting,
  • Graphs and trees,
  • Discrete probability

From computer science of view, it concerns mathematical reasoning, combinatorial analysis, discrete structures, algorithmic thinking & applications and modeling. It provides much of the basic concept for data structures, automate theory, operating systems, database, formal languages and more.

Assignment #2 --- Problem Solving

Question:
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 :

a) **have at least one computers and programming books
b) have only computers
c) have only programming books
d) have both computers and programming books



Solutions:

This is a "find" type problem. So we try to identify unknowns, data and conditions.

The unknowns are the percentage of students who only have computers, the percentage of students who only have Java programming books, and the percentage of students who have both computers and Java programming books.

The data are the three numbers: 221, 159 and 87, representing the number of students who have computers, Java programming books, and both computers and Java programming books, respectively. Note that 221 includes students who have both computers and Java programming books as well as people who have only computers. Similarly for 159.

The conditions are not explicitly given in the problem statement. But one can see that the percentages must add up to 100, and they must be nonnegative.

First let us consider the unknowns in more detail. To calculate the percentage of the students who have only computers, for example, we need the number of students who have at least one of computers and Java programming books, and the number of students who have only computers. Thus actually two unknowns are involved in each of the required percentages, and the real unknowns are the number of students in each of the categories, and the number of students who have at least one of computers and Java programming books.

Next let us look at the data. First the number 221 is the number of students who have computers. But that is not necessarily that of the students who have only computers. It includes that and the number of students who have both computers and Java programming books. Similarly for the second number 159.

Let us use symbols to represent each of the unknowns: Let C represent the number of students who have only computers, J that of the students who have only Java programming books, and T that of the students who have at least one of those things.

Then we have the following relationships among the unknowns:

C + 87 = 221
B + 87 = 159
C + B + 87 = T

From these equations we can easily obtain C = 134, B = 72, and T = 293.
Thus the required percentages are 45.7%, 24.6%, and 29.7%, respectively.

a) The percentage (%) of students who have at least one computers and programming book
= (134 / 293 * 100%) + (72 /293 * 100%)
= 45.7% + 24.6%
=70.3%

b) The percentage (%) of students who have only computers
= 134 / 293 * 100%
= 45.7%

c) The percentage (%) of students who have only Java programming books
= 72 /293 * 100%
= 24.6%

d) The percentage (%) of students who have both computers and Java programming books
= 87 / 293 *100%
= 29.7%

----- Rêve -----

Rêve, meaning "dream" in French, has been chosen as our group's name.
Everyone should have their dreams.
Quoted from the poem of Donna Webster, we have our dreams, and we do believe it.

When life gets tough and the road is long, and it seems there is no light.
When the dreams you had somehow seem lost, don't ever give up the fight.
When you think your life doesn't mean a thing, you must realize we all have gifts.
Look inside yourself and you will find those things you might have missed.

I have a dream and I believe.
The angels said to look inside my heart and hear the song it sings.
Imagine all things are possible, if you only just believe.

We all have the power to change our lives, we're all born with greatness inside.
Don't let your fears hold you back from dreams, and don't ever feel you have to hide.

I have a dream and I believe.
I'll hold my head up high and reach for the stars, I'll find my shining light.
Imagine all things are possible, if you only just believe.

Don't ever give up on dreams, don't ever forget who you really are.
Always know wherever you will go, you'll find that shining star.

I have a dream and I believe.
I have the strength inside, I won't run and hide.
I found my shining star. Imagine all things are possible, if you only just believe.

I have a dream and I believe.
I will survive and grow, this much I know.
Imagine all things are possible, if you only just believe.



**We have 5 members in our group.**


Name: Lai See May

NickName: DaJie (Meaning of big sister) or May May

Matrics Number:
UK 13032

Email: seemay913@hotmail.com





Name: Ooi Cheng Kheng

NickName: ooii~

Matrics Number: UK 13268

Email: kheng_862000@hotmail.com





Name: Lionel Ling Haw Liang

NickName: Lionel, lion or NaiNai

Matrics Number: UK 13461

Email: lionel5302@hotmail.com





Name: Lai Ming See

NickName: Ryanne, lion or SiSi

Matrics Number: UK 13486

Email: ryannelai@yahoo.com





Name: Fam Kok Kim

NickName: Nicholas, nic or XiaoHaiZi (Meaning of small kid)

Matrics Number: UK 13659

Email: inventorfam2006@hotmail.com