PRACTICE
METHOD EXERCISES
Exercises
- Write a method that takes in 3 numbers and displays the average of them to the console.
- Write a method that takes in a String and prints out how many times a space(“ ”) appears in the String.
- Write a method that takes in a String and prints out the sum of all the digits that appear within that String. (e.g. “aa1bc2d3” would return 6).
- Write a method named quartersToDollars. The method should accept an int argument that is a number of quarters and return the equivalent number of dollars as a String. For example, if you pass 4 as an argument, the method should return “$1.00”, and if you pass 7, the method should return “$1.75”.