I am new to java but not new to programming.
I can get everything in my programs to work except for passing the variable. And unless I can resolve this I cannot get any of my programs to run.
I cannot get the value of my variable menuChoice to pass to other methods.
RESULTS
menu A
main
worker
I can get everything in my programs to work except for passing the variable. And unless I can resolve this I cannot get any of my programs to run.
I cannot get the value of my variable menuChoice to pass to other methods.
Code:
***********************************************************
NewAttempt.java
***********************************************************
public class NewAttempt
{
public static menu chooseMenu = new menu();
public static worker doWork = new worker();
public static char menuChoice;
public static void main(String[] args)
{
menu.menu(menuChoice);
System.out.println ("main " + menuChoice);
worker.worker(menuChoice);
}
}
Code:
***********************************************************
menu.java
***********************************************************
import javax.swing.JOptionPane;
public class menu
{
public static char menu(char menuChoice)
{
String menuChoiceString;
menuChoiceString = JOptionPane.showInputDialog
("MENU\n"+
"Choose the letter corresponding to the type of file needed:\n"+
"A - \"A\" students\n" +
"B - \"B\" students\n" +
"C - \"C\" students\n" +
"D - \"D\" students\n" +
"F - \"F\" students\n" +
"G - \"Female\" students\n" +
"M - \"Male\" students\n" +
"I - \"Improving\" students\n" +
"L - a list of \"All\" the students\n" +
"T - students from a particular town\n" +
"X - Exit the menu.\n");
menuChoice = menuChoiceString.charAt(0);
System.out.println ("menu " + menuChoice);
return menuChoice;
}
}
Code:
***********************************************************
worker.java
***********************************************************
public class worker
{
public static void worker(char menuChoice)
{
System.out.println ("worker " + menuChoice);
}
}
***********************************************************
menu A
main
worker
Comment