### Ask Your question

### Search & Filtering

Question 2 (Marks: 50)

The system to be developed for Williams and Son needs to produce the following slip for a

customer once the sale has been concluded.

Please note: For the purpose of this assignment, assume that a customer will only purchase one

unit of each item.

Q.2.1 Write the pseudocode that will produce a slip similar to the one illustrated at

the beginning of the question. Your solution should satisfy the following

requirements:

The solution must illustrate the use of good programming practices;

The solution must make use of a loop;

The loop must make use of a sentinel value.

Q.2.2 The mainline logic of almost every procedural program consists of three parts

namely housekeeping tasks, detail loop tasks and end-of-job tasks. By making

use of flowcharts, show how these parts can be implemented in your solution

for Question 2.1.

Q.2.3 All of your solutions should be structured. Explain why your solution can be

considered a structured solution.

The system to be developed for Williams and Son needs to produce the following slip for a

customer once the sale has been concluded.

Please note: For the purpose of this assignment, assume that a customer will only purchase one

unit of each item.

Q.2.1 Write the pseudocode that will produce a slip similar to the one illustrated at

the beginning of the question. Your solution should satisfy the following

requirements:

The solution must illustrate the use of good programming practices;

The solution must make use of a loop;

The loop must make use of a sentinel value.

Q.2.2 The mainline logic of almost every procedural program consists of three parts

namely housekeeping tasks, detail loop tasks and end-of-job tasks. By making

use of flowcharts, show how these parts can be implemented in your solution

for Question 2.1.

Q.2.3 All of your solutions should be structured. Explain why your solution can be

considered a structured solution.

g(0, Y, Y):- !.

g(X, C, R):- Y is X - 1, C1 is C * 2, g(Y, C1, R).

What is the final value of Y after g(3, 2, Y)?

g(X, C, R):- Y is X - 1, C1 is C * 2, g(Y, C1, R).

What is the final value of Y after g(3, 2, Y)?

Many devices are build and programmed with another computer than How the first computer was programmed to do something?

1. When the following are true? The following symbols are used:

~ - negation,

v – disjunction,

& - conjunction,

-> - implication

1. p & ~p v q

2. ~(x v y) = ~x & ~y

3. ~( a -> ~b)

For each of the following, under what circumstances are they TRUE

For example, question 1 is true only when q is true

TRUE 1, FALSE 0

This is about boolean logic

Conjunction: a AND b, a ∩ b, a & b, a && b

True only if both a and b are true

Disjunction: a OR b, a ∪ b, a || b ,

False only if both a and b are false

Negation: NOT a

True only if a is false

Implication: a IMPLIES b

False only when a true and b false

Equivalence: a IS EQUIVALENT TO b, a = b, a == b ,

True when a and b are the same

~ - negation,

v – disjunction,

& - conjunction,

-> - implication

1. p & ~p v q

2. ~(x v y) = ~x & ~y

3. ~( a -> ~b)

For each of the following, under what circumstances are they TRUE

For example, question 1 is true only when q is true

TRUE 1, FALSE 0

This is about boolean logic

Conjunction: a AND b, a ∩ b, a & b, a && b

True only if both a and b are true

Disjunction: a OR b, a ∪ b, a || b ,

False only if both a and b are false

Negation: NOT a

True only if a is false

Implication: a IMPLIES b

False only when a true and b false

Equivalence: a IS EQUIVALENT TO b, a = b, a == b ,

True when a and b are the same