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.

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.

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 the price
Make an order in advance and get the best price
Pages (550 words)
$0.00
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
How it works
Receive a 100% original paper that will pass Turnitin from a top essay writing service
step 1
Upload your instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
Pro service tips
How to get the most out of your experience with Answers Market
One writer throughout the entire course
If you like the writer, you can hire them again. Just copy & paste their ID on the order form ("Preferred Writer's ID" field). This way, your vocabulary will be uniform, and the writer will be aware of your needs.
The same paper from different writers
You can order essay or any other work from two different writers to choose the best one or give another version to a friend. This can be done through the add-on "Same paper from another writer."
Copy of sources used by the writer
Our college essay writers work with ScienceDirect and other databases. They can send you articles or materials used in PDF or through screenshots. Just tick the "Copy of sources" field on the order form.
Testimonials
See why 20k+ students have chosen us as their sole writing assistance provider
Check out the latest reviews and opinions submitted by real customers worldwide and make an informed decision.
Business Studies
Great paper thanks!
Customer 452543, January 23rd, 2023
Psychology
I requested a revision and it was returned in less than 24 hours. Great job!
Customer 452467, November 15th, 2020
Psychology
Thank you. I will forward critique once I receive it.
Customer 452467, July 25th, 2020
Political science
Thank you!
Customer 452701, February 12th, 2023
Technology
Thank you for your work
Customer 452551, October 22nd, 2021
Political science
I like the way it is organized, summarizes the main point, and compare the two articles. Thank you!
Customer 452701, February 12th, 2023
Accounting
Thank you for your help. I made a few minor adjustments to the paper but overall it was good.
Customer 452591, November 11th, 2021
Education
Thank you so much, Reaserch writer. you are so helpfull. I appreciate all the hard works. See you.
Customer 452701, February 12th, 2023
Finance
Thank you very much!! I should definitely pass my class now. I appreciate you!!
Customer 452591, June 18th, 2022
11,595
Customer reviews in total
96%
Current satisfaction rate
3 pages
Average paper length
37%
Customers referred by a friend
OUR GIFT TO YOU
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat