Posted By:
kaybee_kays
Posted On:
Thursday, April 18, 2002 01:39 PM
I have the following problems: 1) unabale to go back to the main menu from option 1 2) unable to sort 3) unable to write to a file. The program below works, but I really need the above tasks sorted out. Please help Been doing this all day long!!! This is what I have done: import java.io.*; //import all classes in java.io package import java.util.*; public class enter { public static void main(String[] args) throws IOException { String names [] = new String [32]; Getname getname = new Getname(); getname.tname = names; getname.menu
More>>
I have the following problems:
1) unabale to go back to the main menu from option 1
2) unable to sort
3) unable to write to a file.
The program below works, but I really need the above tasks sorted out. Please help
Been doing this all day long!!!
This is what I have done:
import java.io.*; //import all classes in java.io package
import java.util.*;
public class enter
{
public static void main(String[] args) throws
IOException
{
String names [] = new String [32];
Getname getname = new Getname();
getname.tname = names;
getname.menu();
}
}
class Getname
{
BufferedReader br = new BufferedReader( new
InputStreamReader( System.in ) );
List l = new java.util.LinkedList();
String tname[];
public void menu() throws IOException
{
//outer:
//while (true) {
System.out.println("
Please Select One of the following :");
System.out.println("
1- Enter New Data");
System.out.println("
2- Display Unsorted data");
System.out.println("
3- Display sorted data");
System.out.println("
4- Save Unsorted data");
System.out.println("
5- Exit");
int input = System.in.read ();
switch (input) {
case '1': getw(); break;
case '2': show(); break;
case '3': sort(); break;
// case (4): save(); break;
case '5': break;
default: System.out.println("
Wrong C
hoice !!! ");
}
}
public void show()
{
int i;
for (i=0; i
< tname.length;i++)
{
System.out.println("Name Number "+i+" is "+tname[i]);
}
}
public void getw()
throws IOException
{
int i;
inner:
for (i=0; i
< 32; i++)
{
System.out.println("Enter Names please");
String input = br.readLine();
if (input.equals("quit")) {break inner;}
input=tname[i];
l.add( input );
}
}
public void sort()
{
// java.util.Collections.sort( tname );
}
}
<<Less