Solved

Algorithm Fragment

Posted on 2010-08-16
3
319 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: Nadia
Suppose you use Uber application as a rider and you request a ride to go from one place to another. Your driver just arrived at the parking lot of your place. The only thing you know about the ride is the license plate number. How do you find your U…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

18 Experts available now in Live!

Get 1:1 Help Now