Course Content
Computer Science 2010 : Olevel : Free Trail Course

Motorway police want you to record the speed of 50 cars at the start of the day and will charge 500 rupees to each car if it crosses the limit of 120. If its speed is less than or equal to 120, the system would display a message indicating normal speed. At the end, it should output the total fine collected and the total number of cars for whom the fine was collected.

Pseudocode:

  • DECLARE SPEED : INTEGER
  • CONSTANT FINE : INTEGER ← 500
  • DECLARE CAR : INTEGER
  • DECLARE TOTALFINE : INTEGER
  • DECLARE X : INTEGER ←1
  • FOR X←1 TO 50 
    • OUTPUT “ENTER CAR SPEED”
    • INPUT SPEED
    • IF SPEED > 120
    • THEN
      • OUTPUT “CHALLAN ISSUED”
      • TOTALFINE ← TOTALFINE + FINE
    • CAR ← CAR + 1
    • ELSE
      • OUTPUT “ NORMALSPEED”
    • ENDIF
  • ENDFOR
  • OUTPUT “TOTAL FINE COLLECTED : ”, TOTALFINE
  • OUTPUT “TOTAL CARS: “, CAR

Python Code : run it and you will see enter 50 speed is difficult

With  step 10 the code will only check 5 cars. run the code  :

Recreate your own code here :