CAS Community   >   Resources   >  

Program: Example of switch-case statement to count up votes (GCSE)

Uses a switch-case statement to determine what kind of vote has been entered. Displays totals for each.

Phil Gardner

Created by Phil Gardner
last edited Mar 16 2021 by Phil Gardner

Fast food, fast program…

Example of switch-case statement being used to count up different votes as they are typed in.

Note you can “stack up” cases e.g. capital p and lower-case P together to do the same thing.

Paste code and run in or compile on a Raspberry Pi, Apple Mac, Linux PC or Windows PC.

Blog here with more details on how to compile programs.

Downloaded 66 times.


This resource has attached files: to access these files, please tick the box below to assent to the license terms
License: The resources on CAS website are under Creative Commons Attribution-Share Alike 3.0 licence unless otherwise specified by the resource creators.

You must confirm that you have read and agree the licence's ToS before you can download the attachments of this resource.

I have read the licence agreement of this resource and agree to abide by its terms and conditions.

Feedback and Comments

Available when logged in (join via the front page, for free):
  • View 0 comments on this resource.
  • View resource history, links to related resources.
  • Leave feedback for the author(s), or help by editing the resource.

All Rights Reserved © Computing At School 2021
Using the websiteDisclaimer of liabilityCookies policyPrivacy notice