// CSE 142 Lecture 5 // Parameters // Prints a chant from the Simpsons to demonstrate parameters. public class ChantExample { public static void main(String[] args) { chant(1); // We can pass an expression as well. The expression // is evaluated, and the resulting value is passed. chant(11 % 4); chant(5 / 2); // Uncommenting this results in a compiler error // We must pass a parameter to chant, otherwise chant // won't have a value for times //chant(); // Uncommenting this results in a compiler error // chant needs an int, but we can't convert from a // double to an int. //chant(2.7); // } public static void chant(int times) { for (int i = 1; i <= times; i++) { System.out.println("You don't win friends with salad."); } System.out.println(); } }