// This file contains several sample problems discussed in lecture. This // file contains the problem specifications in case you want to work on them // on your own. import java.util.*; public class Methods { // Write a method called digitSum that takes an integer n as a parameter // and that returns the sum of the digits of n. Assume that n is >= 0. // Write a method called roll7 that simulates the rolling of two dice until // their sum is equal to 7. The method should print each roll and its sum // and show a count of how many rolls it took to get to 7, as in: // 3 + 5 = 8 // 2 + 1 = 3 // 1 + 4 = 5 // 3 + 4 = 7 // sum of 7 after 4 rolls // You may assume that an import on java.util is included in the program so // that you can construct a Random object. You must exactly reproduce the // format of this sample execution. // Write a method called hasOddDigit that takes an integer as a parameter // and that returns true if it has an odd digit, false if it does not. // Write a method called stutter that takes a string as a parameter and // that returns a new string where each letter of the original string has // been replaced with two of that letter. For example, stutter("hello") // should return "hheelllloo" // Write a method called called season that takes two integers as // parameters representing a month and day and that returns a String // indicating the season for that month and day. Assume that months are // specified as an integer between 1 and 12 (1 for January, 2 for February, // and so on) and that the day of the month is a number between 1 and 31. // If the date falls between 12/16 and 3/15, you should return "Winter". If // the date falls between 3/16 and 6/15, you should return "Spring". If the // date falls between 6/16 and 9/15, you should return "Summer". And if the // date falls between 9/16 and 12/15, you should return "Fall". // On your own: write a method called reverse that takes an integer as a // parameter and that returns the reverse of the number. For example, // reverse(38042) should return 24083. // on your own: Write a method called noSpaces that takes a String as a // parameter and that returns a new string that contains the nonspace // characters of the original. For example, noSpaces("how are you?") // should return "howareyou?" (see textbook page 236 for a solution) // on your own: Write a method called reverse that takes a string as a // parameter and that returns a new string that has the same text in // reverse order. For example, reverse("hello") should return "olleh" }