return a param to main method then using switch
Hi there,
I am trying to call on a method, and define a parameter to be passed back up to the main method. From there I am trying to use a switch statement to print out different messages. However, the param is never passed back to the main. Below is the code. If anyone has any ideas please let me know.
Thanks much....
/////////////////////////////code/////////////////////////////////
/*
* Main.java
*
* Created on February 17, 2007, 12:27 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package temp;
import java.util.Scanner;
/**
*
* @author dwilmes
*/
public class Main
{
/** Creates a new instance of Main */
public Main()
{
}
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
char number = '\0';
menu(number);
System.out.println("you are in main the value of number is " + number);
switch (number)
{
case 'A':
System.out.println("You entered A.");
break;
case 'B':
System.out.println("You entered B.");
break;
case 'C':
System.out.println("You entered C.");
break;
default:
System.out.println("That's not A, B, or C!");
}
}
private static char menu(char number)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter A, B, or C: ");
number = keyboard.nextLine().charAt(0);
System.out.println("you are in menu method the value of number is " + number);
return number;
}
}

