import javax.swing.*; public class MethodsPractice { public static void main(String[] args) { //countToTen(); //countToNumber(35); //countToNumber(getNumberFromUser()); //Be sure you understand this method call!!! ////////// METHOD OVERLOADING /////////////// //printGreeting(); //printGreeting("How are you?"); //printGreeting("Hi", 10); //printGreeting("Hi", 10.5); //ERROR! (Why?) System.out.println(getNumBet1and10()); System.out.println(); System.exit(1); //needed to properly "clean up" our program //after using JOptionPane //System.exit terminates the JVM } //end of main method //counts from 1 to 10 with a space in between public static void countToTen() { for (int i=1; i<=10; i++) System.out.print(i + " "); System.out.println("\n"); } //end of method countToTen //counts from 1 to 'arg' public static void countToNumber(int arg) { for (int i=1; i<=arg; i++) System.out.print(i + " "); System.out.println("\n"); } //end of method countToNumber //read integer from user, parse it and return the value public static int getNumberFromUser() { int num; String s; s = JOptionPane.showInputDialog("Enter an integer number: "); num = Integer.parseInt(s); return num; } //reads a double from the user between -10 and +10 //if the user enters a number outside -10 to +10, //keeps prompting the user until they do... public static double getNumBet1and10() { double num; String s; do { s = JOptionPane.showInputDialog("Enter a double between -10 and +10:"); num = Double.parseDouble(s); } while (num<-10 || num>10); return num; } //end of method getNumBet1and10() //outputs 'Hello!' and a new line to the screen public static void printGreeting() { System.out.println("Hello!"); System.out.println(); } //end of method printGreeting //outputs 'greeting' to the screen public static void printGreeting(String greeting) { System.out.println(greeting); System.out.println(); } //end of printGreeting method //outputs 'greeting' to the screen 'n' times public static void printGreeting(String greeting, int n) { for (int i=0; i