import java.io.*;
import java.util.*;
import java.net.*;
public class MenuApp
{
public static void main(String[] argStrings)
{
Scanner keyboard = new Scanner(System.in);
BufferedReader in;
String read;
int selection = 0;
do
{
System.out.println("0 - exit");
System.out.println("");
System.out.println("1 - Import Citys & Temperatures from File");
System.out.println("");
System.out.println("2 - Display Citys & Temperatures on Screen");
System.out.println("");
System.out.println("3 - Sort City's into Alphabetical Order");
System.out.println("");
System.out.println("4 - Sort Temperatures into descending order");
System.out.println("");
System.out.println("5 - Display Highest Temperature on Screen");
System.out.println("");
System.out.println("6 - Display Lowest Temperature On Screen");
System.out.println("");
System.out.println("7 - Enter New Data");
System.out.println("");
System.out.print("Enter selection > ");
selection = keyboard.nextInt();
switch (selection)
{
case 0: System.out.println("Exit selected");
break;
case 1: try {
String sCurrentLine;
BufferedReader br = new BufferedReader(new FileReader("C:\\test.txt"));
while ((sCurrentLine = br.readLine()) != null) {
System.out.println(sCurrentLine);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
break;
case 2: System.out.println("My telephone number is 01202999111");
break;
case 3: System.out.println("My telephone number is 01202999111");
break;
case 4: System.out.println("My telephone number is 01202999111");
break;
case 5: System.out.println("My telephone number is 01202999111");
break;
case 6: System.out.println("My telephone number is 01202999111");
break;
case 7: System.out.println("My telephone number is 01202999111");
break;
default:
System.out.println("Error: " + selection + " input. selection must be in the range 0 to 2");
}
} while (selection != 0);
}
}
This is my Code, I'm trying to get it to read a text file that contains citys and temperatures.
when I press Option 1 I need it to read the file and store it, not print to screen.
The 2nd option then needs to print the file to screen.
then I need to sort the citys into alphabetical order using some sort of an array.
Please help me, as I havent got a clue how to do this!
Thanks
Mode Edit:
This post has been edited by Addio569: 09 February 2009 - 12:08 PM

New Topic/Question
Reply




MultiQuote





|