×

Challenges

  1. Not started

  2. Not started

  3. Not started

  4. Not started

  5. Not started

  6. Not started

  7. Not started

  8. Not started

  9. Not started

  10. Not started

  11. Not started

  12. Not started

  13. Not started

Challenge 4.2

Count dots on 5 black and white cards (using a loop)

Challenge Level: Growing experience

Requirement:

Write a program that asks the end user to enter 5 black and white cards representing bits ('B' for black and 'W' for white which are entered one at a time) and displays the total number of dots as the output. Use a loop for this challenge, so it could be changed to work for a different number of cards.

Hints
  • Make a variable called “total number of dots” and set its value to 0. Make another variable called “number of dots” and set its value to 16. Add the value of “number of dots” to the value of “total number of dots” every time the end user enters ‘W’ as the input. Repeat this 5 times dividing the value of “number of dots” by 2 each time. Display the “total number of dots” as the output.
  • Use the 'Repeat' block to run the blocks inside a specified number of times. In this challenge you need to repeat the blocks 5 times.
  • The 'If' block checks if the condition is true and then runs the blocks inside of the if block.
Programming Reminders

Output statements

Output a string directly
Blocks showing how to output a string
Output a variable
Blocks showing how to output a variable

Variables

Set a variable as a string
Blocks showing how to set a variable as a string
Set a variable as an integer
Blocks showing how to set a variable as an integer
Set a variable from a calculation
Blocks showing how to set a variable from a calculation
Set a variable from a user input (text)
Blocks showing how to set a variable from a user input (text)
Set a variable from a user input (number)
Blocks showing how to set a variable from a user input (number)
Add one to a value
Blocks showing how to add one to a value

Conditionals

Find out the discount on fruit
Blocks showing how to use conditional blocks

Loops

Output string 10 times
Blocks showing how to output a string
Output number until number reaches 10
Blocks showing how to output a string
Recommended Blocks
Number block
String block
Ask and wait for text block
Say block
Equality block
Set variable to block
Custom variable block
If block
Repeat block

Create your program in the editor below

Your submission results will be displayed here

Input Expected output Received output Status
B
W
W
B
W
13

                
Not yet run ?
B
B
B
B
B
0

                
Not yet run ?
W
W
W
W
W
31

                
Not yet run ?