Skip to content
latazzajones edited this page May 19, 2015 · 5 revisions

#Day 1: 1.1 Write a program that tells you the following:

  • Hours in a year. How many hours are in a year?
  • Minutes in a decade. How many minutes are in a decade?

1.2

  • Your age in seconds. How many seconds old are you? (I’m not going to check your answer, so be as accurate—or not—as you want.)

1.3

  • Our dear author’s age. If I am 1,025 million seconds old (which I am, though I was in the 800 millions when I started this book), how old am I?

(These exercises are taken from Chris Pine's Book Learn to Program)

#Day 2 2.1

  • Full name greeting. Write a program that asks for a person’s first name, then middle, and then last. Finally, it should greet the person using their full name.

2.2

  • Bigger, better favorite number. Write a program that asks for a person’s favorite number. Have your program add 1 to the number, and then suggest the result as a bigger and better favorite number. (Do be tactful about it, though.)

(These exercises are taken from Chris Pine's Book Learn to Program)

#Day 3 3.1

  • “99 Bottles of Beer on the Wall.” Write a program that prints out the lyrics to that beloved classic, “99 Bottles of Beer on the Wall.”

3.2

  • Boring Bar Date. Whatever you say to your date (whatever you type in), it should respond with this: Hu!?!? Um - YA! I CAN'T HEAR YOU! THE MUSIC'S TOO LOUD! unless you shout it (type in all capitals). If you shout, your date can hear you (or at least he or she thinks so) and yells back: NO, NOT SINCE 1984! To make your program really believable, have your date shout a different year each time, maybe any year at random between 1984 and 1998. (This part is optional and would be much easier if you read the section on Ruby’s random number generator on page 38.) You can’t stop talking to your date until you shout BYE.
  • Hint 1: Don’t forget about chomp! 'BYE' with an Enter at the end is not the same as 'BYE' without one!
  • Hint 2: Try to think about what parts of your program should happen over and over again. All of those should be in your while loop.
  • Hint 3: People often ask me, “How can I make rand give me a number in a range not starting at zero?” Well, you can’t; rand just doesn’t work that way. So, I guess you’ll have to do something to the number rand returns to you.
  • Boring Bar Date extended. What if your date doesn’t want you to leave? When you shout BYE, he or she could pretend not to hear you. Change your previous program so that you have to shout BYE three times in a row. Make sure to test your program: if you shout BYE three times but not in a row, you should still be talking to your date.

Clone this wiki locally