Docsity

Methods Worksheet: Identifying Appropriate Method Headers for Various Functions, Study notes of Computer Science

Toggle sidebar
bg1
MAT 2170 — Methods Worksheet — Spring 09
For each of the following method descriptions, give the most appropriate method header.
1. Determines whether two characters are consecutive alphabetically
2. Breaks a string into “words” and displays these words so that no more than 50 characters are
displayed on each line of output (if possible)
3. Creating a movingCircle object with random speed and displacement (similar to the
createFilledCircle method), given the initial location, size and color desired.
4. Calculates xygiven the integers xand y
5. Determines the number of digits in a positive integer
6. Given a prompt, displays it then determines whether the user entered “yes” or “no”
7. Reports the result of rolling a die
8. Reports the result of rolling a pair of dice
9. Given a numeric version of the date (day, month, and year), return a string version consisting of
the day, a hyphen, the first three letters of the corresponding month, and the last 2 digits of the
year.
10. Determines whether a character is an English consonant
pf2

Partial preview of the text

Download Methods Worksheet: Identifying Appropriate Method Headers for Various Functions and more Study notes Computer Science in PDF only on Docsity!

For each of the following method descriptions, give the most appropriate methodMAT 2170 — Methods Worksheet — Spring 09 header.

  1. Determines whether two characters are consecutive alphabetically
  2. Breaks a string into “words” and displays these words so that no more than 50 characters aredisplayed on each line of output (if possible)
  3. Creating a createFilledCircle movingCircle method), given the initial location, size and color desired. object with random speed and displacement (similar to the
  4. Calculates xy^ given the integers x and y
  5. Determines the number of digits in a positive integer
  6. Given a prompt, displays it then determines whether the user entered “yes” or “no”
  7. Reports the result of rolling a die
  8. Reports the result of rolling a pair of dice
  9. Given a numeric version of the date (day, month, and year), return a string version consisting ofthe day, a hyphen, the first three letters of the corresponding month, and the last 2 digits of theyear.
  10. Determines whether a character is an English consonant
  1. Given an English word, returns the plural of that word
  2. Given an integer, returns a string indicating the corresponding ordinal number (e.g., 1st, 2nd,... )
  3. Given acommas at every third position, starting on the right. string of decimal digits representing a number, produces a string formed by inserting
  4. Given anposition, starting on the right. integer, produces a string representing the number with commas inserted at every third
  5. Given an integer between 0 and 999,999, produces a string that represents that number in words(like on a check)
  6. Calculates the value of PI to 9 decimal places
    1. Devise a general algorithm for a method which creates a string representing a random card froma complete deck of 52 playing cards; rank ((Hearts, Clubs, Diamonds, Spades). For example:Ace, 2, 3, ...10, Jack, Queen, King Queen of Diamonds ) and suit