Q1: [JF edited] In the language of an alien race, all words take

Added on - 16 Sep 2019

  • Dissertation

    type

  • 1

    pages

  • 308

    words

  • 43

    views

  • 0

    downloads

Showing pages 1 to 1 of 1 pages
Q1:[JF edited] In the language of an alien race, all words take the form of Blurbs. A Blurb is aWhoozitfollowed bybetween zero and tenWhatzits. AWhoozitis the character 'x' followed by between one and ten'y's. AWhatzitis a 'q'followed by either a 'z' or a 'd', followed by aWhoozit. Design and implement a recursive program that generates 10random Blurbs in this alien language. (Hint: start by trying to generateWhoozits,Whatzits, and Blurbs by hand and onpaper. Be sure to follow that order. Once you have a feeling for the structure of the language, then start to think about howyou might program it.) [15 points]Sample Output:Q2:Considering thelanguagejust discussed, write a program that reads a string from the user, and checks whether or notis a valid sentence. If it is valid, it prints "The word is fine.", otherwise it prints "The word is a mess!" The program shouldloop and ask the user for new input until they enter DONE. (Hint: tryWhoozitsfirst, followed byWhatzits, and thenBlurbs.For each method, test it by running it on known valid strings generated by the methods you had to write for Q1.)Note: if ithelps you, you can omit checking for the maximum number of timesWhatzitsor'y'soccur (e.g., "between one and ten"becomes "one or more").[20 points]Sample Output:
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Unlock This Document