State flowchart that take temperature input using pseudocode, Data Structure & Algorithms

Assignment Help:

Write an algorithm using pseudocode which takes temperatures input over a 100 day period (once per day) and output the number of days when the temperature was below 20C and the number of days when the temperature was 20C or above.

(NOTE: since the number of inputs is known, a for ... to loop can be used. However, a while loop or a repeat loop would work just as well).

total1 = 0: total2 = 0

for days = 1 to100

input temperature

if temperature < 20 then total1 = total1 + 1

else total2 = total2 + 1

endif

next

print total1, total2

This is a good illustration of an algorithm which could be written using the case construct instead of if ... then ... else. The following section of code replaces the statements if temperature < 20 then ...... endif:

case temperature of

1: total1 = total1 + 1

2: total2 = total2 + 1

Endcase

 


Related Discussions:- State flowchart that take temperature input using pseudocode

Time complexity, Run time complexity of an algorithm is depend on

Run time complexity of an algorithm is depend on

Program, insertion and deletion in a tree

insertion and deletion in a tree

Time complexity, how to learn about time complexity of a particular algorit...

how to learn about time complexity of a particular algorithm

Cache simulator, how to design a cache simulator with 4-way set associative...

how to design a cache simulator with 4-way set associative cache

Flowchart, conversion of centrigral to frahenhit

conversion of centrigral to frahenhit

Row major representation, Row Major Representation In memory the primar...

Row Major Representation In memory the primary method of representing two-dimensional array is the row major representation. Under this representation, the primary row of the a

Tree traversal, Q. What do you understand by the tree traversal? Write down...

Q. What do you understand by the tree traversal? Write down the procedure for traversing a binary tree in preorder and execute it on the following tree.    Ans: Th

#title.state charts., explain two strategies to implement state charts with...

explain two strategies to implement state charts with the help of an example of each.

Sequential files, In this section, we will discuss about Sequential file or...

In this section, we will discuss about Sequential file organization. Sequential files have data records stored in a particular sequence. A sequentially organized file might be stor

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd