Return To CS 110 Home

Colour Theme   Font Size Options
 
   
   
   
Scrabble Style Game

Scrabble Style Game


Video Summary: https://youtu.be/gVOZWXWVd2Y


In this exercise, you are going to create a program that generates a given number of consonants and vowels, scrambles them, and presents them to the user. Start from this code given:


To accomplish this exercise, you will need:

  1. Two character returning functions, generateConsonant and generateVowel, which will each receive their respective character array, generate a random number, and return that character. The prototypes are already given
  2. A scramble function that takes the reference to the string of characters generated in the previous steps, and scrambles it by generating two random numbers based on the size of the string, and then swapping the characters in these positions in the string. To ensure it is sufficiently scrambled, loop it some arbitrary number of times, such as 20. This prototype is also already given

Suggested steps:

  1. Prompt the user for the number of consonants they want, and use a loop to add that many consonants by calling generateConsonant the given number of times, adding each returned character to the letters string
  2. Repeat the process for vowels
  3. Scramble the string
  4. Output the result

When you are finished, your output might look like this:

Enter how many consonants to generate
5
Enter how many vowels to generate
5
rzaeoaodzp

Solution