Sie sind auf Seite 1von 2
DEPARTMENT OF ELECTRONIC ENGINEERING TECHNOLOGY VGT114 Technology System Programming I Lab Module LABSHEET 2 DATE

DEPARTMENT OF ELECTRONIC ENGINEERING TECHNOLOGY

VGT114 Technology System Programming I Lab Module

LABSHEET

2

DATE

TITLE

Pseudocode & Flowchart

MATRIC NO

CHAPTER

Introduction to Problem Solving

NAME

TASK A: Answer the following question

Based on the following information regarding input, output and process, write the pseudocode and flowchart to solve the problem.

Problem: Determine whether profit, return capital or loss Input:

Purchase price

Selling price

Output: Message "Profit" or "Return Capital" or "Loss" Process:

Difference = Purchase price - Selling price If Difference > 0, Output = "Profit" If Difference = 0, Output = "Return Capital" If Difference < 0, Output = "Loss"

TASK B: Trace output

Trace the following pseudocode and record the output statements in the following table.

This program prints a pattern within loops.

Read value Set counter = 0 WHILE value is not 0 IF value is not 2 or 4 Print "*"

ELSE

Print "@"

ENDIF Print ">" counter = counter + 1 Read value ENDWHILE

Input Value

 

Output Statement

1

2

3

4

5

6

3

0

 

3

2

0

5

6

8

4

 

P a g e

1

|

2

TASK C: Problem solving

Write the pseudocode to show the algorithm to solve the following problems:

1. Student will only pass if the marks is higher than 50.

2. To find Z, you have to find the number of X which are higher than 10.

3. Your grade point average (GPA) is calculated by dividing the total amount of grade points earned by the total amount of credit hours attempted. First, multiply each grade points by the number of credits associated with the course. Add these values together. Second, divide the total by the number of total credits you earned.

4. Here are the steps to calculate standard deviation Step 1: Find the mean. Step 2: For each data point, find the square of its distance to the mean. Step 3: Sum the values from Step 2. Step 4: Divide by the number of data points. Step 5: Take the square root.