?
Solved

Algorithm Fragment

Posted on 2010-08-16
3
Medium Priority
?
398 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 53

Accepted Solution

by:
Infinity08 earned 500 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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

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…
When there is a disconnect between the intentions of their creator and the recipient, when algorithms go awry, they can have disastrous consequences.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

762 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