|
-
Sep 5th, 2008, 05:41 PM
#1
Thread Starter
New Member
hi someone help pls
I have these questions which i can't get my head round. Can someone show me the workings and thus the answers PLEASE!
For the algorithm below, state the values of Total and Number that would be printed.
Start
Number !2
Total ! Number
While Number ≤ Total
Total ! Total + Number
Number ! Number * Number
End While
Print Total, Number
End
Total
Number
QUESTION 2
A computerised machine sorts fruit by weight. It uses a program that directs the fruit through three different gates according to weight. Below is a small segment of that program.
message ! “Fruit is undersized”
fruit_count ! 0
Repeat
good_fruit ! true
Close all gates
Input (fruit_weight)
If (fruit_weight > 30.00) then
Open (gate1)
fruit_count ! fruit_count + 1
Else
If (fruit_weight > 20.00) then
Open (gate2)
fruit_count ! fruit_count + 1
Else
good_fruit ! false
Open (gate3)
Endif
Endif
If not (good_fruit) then
Output (message)
Endif
Until eof ***end of fruit
Output (fruit_count)
a. Identify each variable shown in the table below as one of the following variable types: text, date, boolean, integer, floating point.
Variable Type
fruit_count
message
good_fruit
Can anyone help me here ... i've been working on this and looked at a few books? I need the workings pls?
Many thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|