Hello All, this is my first post, so bear with me... My problem is with the following code. I have a simple menu setup to do some number conversions, and everything compiles properly. When i run the code, i end up with the Java VM (in bluej) just running endlessly, and according to the debug, this is happening before any code is processed. the classes Decimal, Binary, Hexadecimal and Menu run properly on their own, however when i try and run them from the driver, I encounter this problem. Please help!
import java.io.*;
import java.lang.*;
import java.util.Scanner;
public class Driver
{
public static void main(String[] args)throws IOException {
LineWriter lw = new LineWriter("csis.txt");
int selection;
Decimal dec = new Decimal();
Binary bin = new Binary();
Hexadecimal hex = new Hexadecimal();
Menu menu = new Menu();
do{
menu.display();
selection=menu.GetSelection();
switch (selection){
case '1': dec.getDec();
{break;}
case '2': dec.getHex();
{break;}
case '3': bin.getBin();
{break;}
case '4': bin.getHex();
{break;}
case '5': hex.getHex();
{break;}
case '6': hex.getDec();
{break;}
case '0': System.out.println("Goodbye");
{break;}
}
}while (selection !=0);
}
}
import java.io.IOException;
import java.io.*;
import java.util.Scanner;
public class Menu {
Scanner scan = new Scanner(System.in);
int selection = scan.nextInt();
public void display()
{
System.out.println("Please choose an option from the following:");
System.out.println("[1] Convert Decimal to Binary");
System.out.println("[2] Convert Decimal to Hexadecimal");
System.out.println("[3] Convert Binary to Decimal");
System.out.println("[4] Convert Binary to Hexadecimal");
System.out.println("[5] Convert Hexadecimal to Decimal");
System.out.println("[6] Convert Hexadecimal to Binary");
System.out.println("[0] Exit");
System.out.println("\n");
System.out.println("You entered: " + selection);
}
public int GetSelection()
{
return selection;
}
}