public class Project0
{
//Test your methods here
public static void main(String[] args)
{
}
/* Function 1
* Implement the function to always return the 6th character of a String.
* Ignore the possibility of invalid Strings, or Strings that are not long enough.
* REMINDER: The first character of a String is at index 0.
*/
public static char getSixthCharOfString(String str)
{
}
/* Function 2
* Find and return the maximum value among three integers.
* Negative integers may be passed in as parameters.
*/
public static int getMax(int val1, int val2, int val3)
{
}
/* Function 3
* Determine if two Strings are equivalent, regardless of the casing.
* As an example, "Hello", "hello", "HELLO", and "hElLo" should all be considered equivalent.
* Return a boolean indicating whether or not the String is equivalent.
*/
public static boolean isEquivalentWithoutCasing(String str1, String str2)
{
}
/* Function 4
* Given a String of even length (an even number of characters),
* return the 4 characters in the middle.
* As an example, an input of "umbrella" should return "brel".
* You may assume the String will have at least 4 characters, and will be even in length.
*/
public static String middleFour(String str)
{
}
/* Function 5
* Given an integer, return "even" if it is even, and "odd" if it is odd.
*/
public static String isEven(int num)
{
}
/* Function 6
* Given two words as Strings, return the word that would come first in the dictionary.
* You may assume the Strings will be words.
*/
public static String orderedWord(String firstWord, String secondWord)
{
}
/* Function 7
* Given a double x, return the value of the evaluation of the polynomial 3x^3 - 5x^2 + 12x - 16.
*/
public static double polynomial(double x)
{
}
/* Function 8
* Given a String, perform the following:
* 1. If the String has an even number of characters, cut the String in half and keep only the first half.
* 2.a. If the String at this point has an even number of characters, cut the String in half again and keep only the second half.
* 2.b. Otherwise, if the String has an odd number of characters, repeat the String twice.
* 3.a. If the String has more than 10 characters, remove characters from the right until there are only 10 characters.
* 3.b. If the String has less than 10 characters, concatenate "a"s until the String contains 10 characters.
* 3.c. If the String has exactly 10 characters, capitalize all the characters.
* 4. Return the String.
*/
public static String alteration(String str)
{
}
/* Function 9
* You are tasked with taking care of someone with very particular tastes.
* He requires you to serve him lunch everyday with the following features:
* 1. He must be served at 12:00 o'clock (hour 12, minute 0).
* 2. He must be served an odd number of tater tots (e.g. 1, 3, 5, 7, ...).
* 3. He must be served a multiple of 7 candies (e.g. 0, 7, 14, 21, ...).
* Implement this function such that it returns true if all of the requirements
* are met, and return false otherwise.
* You may assume all integer values are greater than or equal to 0.
*/
public static boolean veryParticularLunch(int hour, int minute, int taterTots, int candies)
{
}
/* Function 10
* Given a word in a String, return the String that represents that word in Pig Latin.
* The rules of Pig Latin are:
* 1. If the word starts with a consonant, move the consonant to the end of the word, and add "ay".
* 2. If the word starts with multiple consonants, move all of the consonants to the end of the word, and add "ay".
* 3. If the word starts with a vowel and ends with a consonant, just add "ay".
* 4. If the word starts with a vowel and ends with a vowel, just add "way".
* Some examples:
* 1. "pig" --> "igpay"
* 2. "string" --> "ingstray"
* 3. "int" --> "intay"
* 4. "else" --> "elseway"
* As a reminder, a vowel is one of "a", "e", "i", "o", "u" and sometimes "y",
* and a consonant is any letter that is not a vowel.
* For the purposes of this function, assume words that start with a "y" treat it as a consonant, and
* in all other cases, treat "y" as a vowel.
* You may assume that Rule 2 has a maximum of 3 starting consonants.
* You may ignore invalid Strings, and assume words are always lowercase.
*/
public static String pigLatinWord(String word)
{
}
/* OPTIONAL
* You may want to create a helper function for Function 10, as stated below.
* This function would take a character c, be given information if it was the first character in a word or not,
* and would return a boolean representing whether or not the character should be considered a vowel.
* Refer to the project description to see how you might be able to call this function in your own code.
*/
public static boolean isVowel(char c, boolean first)
{
}
}