Photo AI

P-Cubed wants to know the weight of the heaviest item and the weight of the lightest item - Edexcel - GCSE Computer Science - Question 8 - 2018 - Paper 1

Question icon

Question 8

P-Cubed-wants-to-know-the-weight-of-the-heaviest-item-and-the-weight-of-the-lightest-item-Edexcel-GCSE Computer Science-Question 8-2018-Paper 1.png

P-Cubed wants to know the weight of the heaviest item and the weight of the lightest item. An operator enters weights for each item. The operator enters 0 when fini... show full transcript

Worked Solution & Example Answer:P-Cubed wants to know the weight of the heaviest item and the weight of the lightest item - Edexcel - GCSE Computer Science - Question 8 - 2018 - Paper 1

Step 1

Write an algorithm to meet the requirements.

96%

114 rated

Answer

  1. SET count TO 0
  2. SET heaviest TO 0
  3. SET lightest TO Infinity
  4. REPEAT UNTIL weight IS 0: a. DISPLAY "Enter the weight for the item, 0 to quit:" b. READ weight FROM INPUT c. IF weight < 0 THEN i. DISPLAY "Error. No negatives allowed" ii. CONTINUE TO NEXT ITERATION d. IF weight > heaviest THEN i. SET heaviest TO weight e. IF weight < lightest AND weight > 0 THEN i. SET lightest TO weight f. INCREMENT count BY 1
  5. END REPEAT
  6. DISPLAY "Heaviest: " + heaviest
  7. DISPLAY "Lightest: " + lightest

Join the GCSE students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;