Examples Of Pseudo Code And Desk Check For Algorithms

Algorithm 1: Calculating temperature statistics over a month

1. Draw a defining diagram for the following problem statement
A program that will prompt for and receive the measurements of a rectangle and then calculate the circumference (perimeter) and the area of the rectangle. The program is to continue until a sentinel of 999 is entered.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

2. Develop a solution algorithm for a program that prompts for and obtains the daily temperatures for a whole month and displays the average, minimum, maximum temperature for that month. Your solution should contain a defining diagram, a pseudocode algorithm and a desk check of the algorithm

Your algorithm should first prompt the user for the number of days in the month (x) and then request the user to enter x temperature values. If the user enters a negative number for x then an appropriate message should be displayed.

Once the x number of temperatures have been entered, your algorithm must calculate and display the average, minimum and maximum temperature.

3. Develop an algorithm for the following problem statement using appropriate modularisation techniques. Your solution should contain a defining diagram, a pseudocode algorithm and a desk check of the algorithm.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Your algorithm will produce a list of students from a student file. The file has a record for each unit attempted and result achieved in that unit for each student. Eg. If a student has passed four units and failed two there will be 6 records on the file.

Each record contains the following fields:

Field Name Data Type
Student Id Alphanumeric
Student Name Alphanumeric
Unit Code Alphanumeric
Unit Result Numeric

The algorithm is to read the records from the student file and print a report of all students as well as their results. The report should contain all of the fields properly formatted. For each student there should be a printed summary of their results i.e. a printed line of the number of passed units, the number of failed units and the student’s WAM, the average of all units.

Print page headings and column headings at the top of each page. After printing 50 lines, a new page should be started. At the end of the report, the total number of students; the total number of passed units and the total number of failed units should be printed.

1. Defining diagram is,

Input

Processing

Output

LENGTH

BREADTH

TOKEN (Enter 999 to stop)

·         Check TOKEN = 999, then STOP.

·         Calculate CIRCUMFERENCE = 2(LENGTH x BREADTH)

CIRCUMFERENCE

2. The defining diagram is,

Input

Processing

Output

NUM_DAYS_MONTH

DAILY_TEMP

·         Check NUM_DAYS_MONTH <=0, PRINT ERROR.

·         Enter daily temperature for NUM_DAYS_MONTH one by one using DAILY_TEMP.

·         Calculate MIN_TEMP, MAX_TEMP, AVG_TEMP.

MIN_TEMP, MAX_TEMP, AVG_TEMP

The Pseudo code is,

ALGORITHM1 (MIN_TEMP = 0, MAX_TEMP=0, TOTAL_TEMP=0)

{

INPUT NUM_DAYS_MONTH

IF NUM_DAYS_MONTH <= 0

                PRINT “Enter Positive number”.

ELSE

                FOR (i=1 to NUM_DAYS_MONTH)

                {

                                INPUT DAILY_TEMP(i)

                                SET TOTAL_TEMP = TOTAL_TEMP + DAILY_TEMP(i)

                                i++

}

AVG_TEMP = TOTAL_TEMP / NUM_DAYS_MONTH

FOR (i=1 to NUM_DAYS_MONTH )

                {

                                IF (DAILY_TEMP (i) <= MIN_TEMP) )

                                                {

                                                                MIN_TEMP = DAILY_TEMP (i)

                                                                i++

}

}

FOR (i=1 to NUM_DAYS_MONTH )

                {

                                IF (DAILY_TEMP (i) > MAX_TEMP )

                                                {

                                                                MAX_TEMP = DAILY_TEMP (i)

                                                                i++

}

}

PRINT MAX_TEMP, MIN_TEMP, AVG_TEMP

}

The desk check is,

ALGORITHM1 ()

{

INPUT NUM_DAYS_MONTH

NUM_DAYS_MONTH = 3

IF NUM_DAYS_MONTH <= 0

FALSE

                PRINT “Enter Positive number”.

ELSE

                FOR (i=1 to NUM_DAYS_MONTH)

1 to 3

                {

                                INPUT DAILY_TEMP(i)

40

30

20

                                SET TOTAL_TEMP = TOTAL_TEMP + DAILY_TEMP(i)

TOTAL_TEMP = 40

TOTAL_TEMP = 70

TOTAL_TEMP = 90

                                i++

1

2

3

}

AVG_TEMP = TOTAL_TEMP / NUM_DAYS_MONTH

AVG_TEMP = 30

FOR (i=1 to (NUM_DAYS_MONTH ))

i= 1 to 2

                {

                                IF (DAILY_TEMP (i) <= MIN_TEMP )

TRUE

TRUE

                                                {

                                                                MIN_TEMP = DAILY_TEMP (i)

MIN_TEMP = 30

MIN_TEMP = 20

                                                                i++

2

3

}

}

FOR (i=1 to NUM_DAYS_MONTH )

i=1 to 2

                {

                                IF (DAILY_TEMP (i) > MAX_TEMP)

TRUE

FALSE

                                                {

                                                                MAX_TEMP = DAILY_TEMP (i)

MAX_TEMP = 40

                                                                i++

2

}

}

PRINT MAX_TEMP, MIN_TEMP, AVG_TEMP

MAX_TEMP = 40, MIN_TEMP = 20, AVG_TEMP= 30

}

         

3. The defining diagram is,

Input

Processing

Output

NUM_RECORDS

COUNTER = 0

RECORD(i)

·         Check for NUM_RECORDS

·         COUNT NUM_FAIL for a STUDENT_ID

·         COUNT NUM_PASS for a STUDENT_ID

PRINT 50 RECORDS on each page of REPORT

The pseudo code is,

ALGORITHM2(COUNTER1=0, COUNTER2=0, Counter3 = 0)

{

                INPUT NUMBER_RECORDS

                IF NUMBER_RECORDS < 0

                                PRINT ‘Please enter valid number’.

                FOR (i=1 to NUMBER_RECORDS)

                {

                X= STUDENT_ID(i)

FOR (j = 2 to NUM_RECORDS)

{

IF (X = STUDENT_ID(j))

{

                IF (UNIT_RESULT(j) = PASSED

                                COUNTER1 ++

                ELSE

                                COUNTER2++

}

J++

}

PRINT [STUDENTID, COUNTER1 AS PASSED, COUNTER2 AS FAILED]

PRINT NEW LINE

I++

IF (COUNTER3 >=50)

{

                INSERT PAGE BREAK

                COUNTER3 = 0

}

ELSE

                COUNTER3 ++

}                             

The desk check is,

ALGORITHM2(COUNTER1=0, COUNTER2=0)

COUNTER1=0, COUNTER2=0

next iteration

next iteration

{

                INPUT NUMBER_RECORDS

3

                IF NUMBER_RECORDS < 0

FALSE

                                PRINT ‘Please enter valid number’.

                FOR (i=1 to NUMBER_RECORDS)

i= 1 to 3

                {

                X= STUDENT_ID(i)

X = STUDENT_ID(1)

FOR (j = 1 to NUM_RECORDS)

j= 1 to 3

j= 2to 3

j=3 to3

{

IF (X = STUDENT_ID(j))

TRUE

TRUE

FALSE

{

                IF (UNIT_RESULT(j) = PASSED

TRUE

FALSE

                                COUNTER1 ++

COUNTER1=1

                ELSE

                                COUNTER2++

COUNTER2 = 1

}

J++

j = 2

j=3

j=3

}

PRINT [STUDENTID, COUNTER1 AS PASSED, COUNTER2 AS FAILED]

PRINT STUDENT_ID, PASSED =1, FAILED =1

PRINT NEW LINE

               i++

i=2

IF (COUNTER3 >=50)

FALSE

{

          INSERT PAGE BREAK

           COUNTER3 = 0

}

ELSE

        COUNTER3 ++

COUNTER3=1

}                             

}

The process will continue for 3 records. The first two records are for same student in two different subject, one PASSED and another FAILED, the third record is for another student and PASSED.

Calculate your order
Pages (275 words)
Standard price: $0.00
Client Reviews
4.9
Sitejabber
4.6
Trustpilot
4.8
Our Guarantees
100% Confidentiality
Information about customers is confidential and never disclosed to third parties.
Original Writing
We complete all papers from scratch. You can get a plagiarism report.
Timely Delivery
No missed deadlines – 97% of assignments are completed in time.
Money Back
If you're confident that a writer didn't follow your order details, ask for a refund.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Power up Your Academic Success with the
Team of Professionals. We’ve Got Your Back.
Power up Your Study Success with Experts We’ve Got Your Back.