CS110 Lab # 9

More Practice with Methods




Exercise #1

The Farmer in the Dell is a children's song that most people have sung at one time or another. Write an efficient Java program that displays the lyrics of this song.

    The farmer in the dell
    The farmer in the dell
    Hi-ho, the derro-o
    The farmer in the dell

    The farmer takes a wife
    The farmer takes a wife
    Hi-ho, the derro-o
    The farmer takes a wife

    The wife takes a child
    The wife takes a child
    Hi-ho, the derro-o
    The wife takes a child

    The child takes a nurse
    The child takes a nurse
    Hi-ho, the derro-o
    The child takes a nurse

    The nurse takes a cow
    The nurse takes a cow
    Hi-ho, the derro-o
    The nurse takes a cow

    The cow takes a dog
    The cow takes a dog
    Hi-ho, the derro-o
    The cow takes a dog

    The dog takes a cat
    The dog takes a cat
    Hi-ho, the derro-o
    The dog takes a cat

    The cat takes a rat
    The cat takes a rat
    Hi-ho, the derro-o
    The cat takes a rat

    The rat takes the cheese
    The rat takes the cheese
    Hi-ho, the derro-o
    The rat takes the cheese

    The cheese stands alone
    The cheese stands alone
    Hi-ho, the derro-o
    The cheese stands alone



Exercise #2

The following song is by The Doors and is titled I Looked at You Lyrics. Write a program that displays the lyrics to the screen. Use functions to eliminate redundancy




      I looked at you
      You looked me
      I smiled at you
      You smiled at me

      And we're on our way
      No we can't turn back, babe
      Yeah, we're on our way
      And we can't turn back

      'Cause it's too late
      Too late, too late
      Too late, too late

      And we're on our way
      No we can't turn back, babe
      Yeah, we're on our way

      And we can't turn back, yeah

      I walked with you
      You walked with me
      I talked to you
      You talked to me

      And we're on our way
      No we can't turn back, yeah
      Yeah, we're on our way
      And we can't turn back, yeah

      'Cause it's too late
      Too late, too late
      Too late, too late

      And we're on our way
      No we can't turn back
      Yeah, we're on our way
      And we can't turn back

      'Cause it's too late
      Too late, too late
      Too late, too late