Sei sulla pagina 1di 2

Name : Khrisna Handoko

NIM : 2301944525
Class : LJ01-LEC
Lecturer : Irma Irawati Ibrahim

EXERCISE – SESSSION 7TH (MEETING 3RD TUTOR CLASS)

Individual Assignment

Type: Open Book, Open Note, Internet is allowed.

In the following questions, you will need to:

1. Define a solution diagram


2. Create a solution algorithm using pseudocode
3. Desk check the solution algorithm using two valid test cases.

QUESTION

1. Design an algorithm that will read two numbers and an integer code from the screen. The value
of the integer code should be 1,2,3 or 4. If the value of the code is 1, compute the sum of the
two numbers. If the code is 2, compute the difference (first minus second). If the code is 3,
compute the product of the two numbers. If the code is 4, and the second number is not zero,
compute the quotient (first divided by second). If the code is not equal to 1,2,3 or 4 display an
error message. The program is then to display the two numbers, the integer code and the
computed result to the screen.
Answer :

2. Design an algorithm that will prompt a terminal operator for the price of an article and a pricing
code. Your program is then calculate a discount rate according to the pricing code and print to
the screen the original price of the article, the discount amount and the new discounted price.
Calculate the pricing code and accompanying discount amount as follows:

PRICING CODE DISCOUNT RATE


H 50%
F 40%
T 33%
Q 25%
Z 0%

if the pricing code is Z, the words ‘No discount’ are to be printed on the screen, if the pricing
code is not H, F, T, Q or Z, the words ‘Invalid pricing code’ are to be printed.
3. Design an algorithm that will prompt for, receive and total a collection of payroll amounts
entered at the terminal until a sentinel amount of 999 is entered. After the sentinel has been
entered, display the total payroll amount to the screen.

4. A file of student records contains name, sex, (M of F), age (in years) and marital status (single or
married) for each student. Design an algorithm that will read through the file and calculate the
numbers of married men, single men, married women, and single women, print these numbers
on a student summary report. If any single men are over 30 years of age, print their names and
ages on a separate eligible bachelors report.

Potrebbero piacerti anche