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.

What Will You Get?

We provide professional writing services to help you score straight A’s by submitting custom written assignments that mirror your guidelines.

Premium Quality

Get result-oriented writing and never worry about grades anymore. We follow the highest quality standards to make sure that you get perfect assignments.

Experienced Writers

Our writers have experience in dealing with papers of every educational level. You can surely rely on the expertise of our qualified professionals.

On-Time Delivery

Your deadline is our threshold for success and we take it very seriously. We make sure you receive your papers before your predefined time.

24/7 Customer Support

Someone from our customer support team is always here to respond to your questions. So, hit us up if you have got any ambiguity or concern.

Complete Confidentiality

Sit back and relax while we help you out with writing your papers. We have an ultimate policy for keeping your personal and order-related details a secret.

Authentic Sources

We assure you that your document will be thoroughly checked for plagiarism and grammatical errors as we use highly authentic and licit sources.

Moneyback Guarantee

Still reluctant about placing an order? Our 100% Moneyback Guarantee backs you up on rare occasions where you aren’t satisfied with the writing.

Order Tracking

You don’t have to wait for an update for hours; you can track the progress of your order any time you want. We share the status after each step.

image

Areas of Expertise

Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.

Areas of Expertise

Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.

image

Trusted Partner of 9650+ Students for Writing

From brainstorming your paper's outline to perfecting its grammar, we perform every step carefully to make your paper worthy of A grade.

Preferred Writer

Hire your preferred writer anytime. Simply specify if you want your preferred expert to write your paper and we’ll make that happen.

Grammar Check Report

Get an elaborate and authentic grammar check report with your work to have the grammar goodness sealed in your document.

One Page Summary

You can purchase this feature if you want our writers to sum up your paper in the form of a concise and well-articulated summary.

Plagiarism Report

You don’t have to worry about plagiarism anymore. Get a plagiarism report to certify the uniqueness of your work.

Free Features $66FREE

  • Most Qualified Writer $10FREE
  • Plagiarism Scan Report $10FREE
  • Unlimited Revisions $08FREE
  • Paper Formatting $05FREE
  • Cover Page $05FREE
  • Referencing & Bibliography $10FREE
  • Dedicated User Area $08FREE
  • 24/7 Order Tracking $05FREE
  • Periodic Email Alerts $05FREE
image

Services offered

Join us for the best experience while seeking writing assistance in your college life. A good grade is all you need to boost up your academic excellence and we are all about it.

  • On-time Delivery
  • 24/7 Order Tracking
  • Access to Authentic Sources
Academic Writing

We create perfect papers according to the guidelines.

Professional Editing

We seamlessly edit out errors from your papers.

Thorough Proofreading

We thoroughly read your final draft to identify errors.

image

Delegate Your Challenging Writing Tasks to Experienced Professionals

Work with ultimate peace of mind because we ensure that your academic work is our responsibility and your grades are a top concern for us!

Check Out Our Sample Work

Dedication. Quality. Commitment. Punctuality

Categories
All samples
Essay (any type)
Essay (any type)
The Value of a Nursing Degree
Undergrad. (yrs 3-4)
Nursing
2
View this sample

It May Not Be Much, but It’s Honest Work!

Here is what we have achieved so far. These numbers are evidence that we go the extra mile to make your college journey successful.

0+

Happy Clients

0+

Words Written This Week

0+

Ongoing Orders

0%

Customer Satisfaction Rate
image

Process as Fine as Brewed Coffee

We have the most intuitive and minimalistic process so that you can easily place an order. Just follow a few steps to unlock success.

See How We Helped 9000+ Students Achieve Success

image

We Analyze Your Problem and Offer Customized Writing

We understand your guidelines first before delivering any writing service. You can discuss your writing needs and we will have them evaluated by our dedicated team.

  • Clear elicitation of your requirements.
  • Customized writing as per your needs.

We Mirror Your Guidelines to Deliver Quality Services

We write your papers in a standardized way. We complete your work in such a way that it turns out to be a perfect description of your guidelines.

  • Proactive analysis of your writing.
  • Active communication to understand requirements.
image
image

We Handle Your Writing Tasks to Ensure Excellent Grades

We promise you excellent grades and academic excellence that you always longed for. Our writers stay in touch with you via email.

  • Thorough research and analysis for every order.
  • Deliverance of reliable writing service to improve your grades.
Place an Order Start Chat Now
image

Order your essay today and save 30% with the discount code ESSAYHELP