Solved

Algorithm Fragment

Posted on 2010-08-16
3
333 Views
Last Modified: 2012-05-10
Hi - I have been given these algorithm fragments to examine and answer some questions:

put on hat ;
IF(weather is sunny)
put on sunglasses;
ENDIF
put on shoes;

What items of clothing will be put on a) when it is rainging and b) when it is sunny?

- I imagine that if it is rainging it would be the hat and shoes and if it is sunny it would be the hat, shoes and sunglasses.

Go to shop;
buy milk;
IF(today is Saturday)
buy weekly newspaper;
buy peanuts;
ENDIF
buy bread

- What items will be purchased on a) Thursday b) Saturday?

I think that Thursday would be milk and bread and Saturday would be mild, newspaper, peanuts and bread.

Please could somebody just have a quick look at this and tell me if I'm on the right tracks and if not, let me know where I'm going wrong so that I can understand this.

Thank you in advance
0
Comment
Question by:peploe
  • 2
3 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 125 total points
ID: 33446565
>> - I imagine that if it is rainging it would be the hat and shoes and if it is sunny it would be the hat, shoes and sunglasses.

Correct. The if test is only true if it's sunny, so the if block is only executed is it's sunny.


>> I think that Thursday would be milk and bread and Saturday would be mild, newspaper, peanuts and bread.

Correct too.
0
 

Author Comment

by:peploe
ID: 33446602
Thank you :)
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 33446635
No problem. Glad to be of assistance :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Fuel Volume Formula 31 229
Finding maximum sum of contigious elements. 2 111
how to understand recursion 12 218
Homework Help 5 71
Article by: Nadia
Linear search (searching each index in an array one by one) works almost everywhere but it is not optimal in many cases. Let's assume, we have a book which has 42949672960 pages. We also have a table of contents. Now we want to read the content on p…
The greatest common divisor (gcd) of two positive integers is their largest common divisor. Let's consider two numbers 12 and 20. The divisors of 12 are 1, 2, 3, 4, 6, 12 The divisors of 20 are 1, 2, 4, 5, 10 20 The highest number among the c…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now