RamsTheDon
asked on
interactive java
Guys i'm back again. I know this might sound a bit daft on my part but forgive i'm still a novice.
I've done the hard part of the question but i'm stuttering on the construction of a class that will enable users to enter towns in the command prompt and all details for that particular town pop up.
I've done the following , and forgive i've changed the codes so many times because i'm constantly getting errors and hence it looks a bit messy, someone fresh needs to have a look.
Just to remind the format for each town is eg NAMMOTH:NM:280520:-10550:4 40:464
Nammoth being the town, NM(county code),280520 lat,10550 lon, 440km (east coord) and 464km (north coord).
please feel free to ask me further ? , if u don't understand my ?, i can hardly understand it myself.
THANK YOU
import java.io.*;
public class Distances
{
public static void main(String[] args)
{
try
{
BufferedReader in = new BufferedReader(new FileReader("towns.txt"));
String str;
while ((str = in.readLine()) != null) {
towns.add(new Town(str));
{
int town_name;
if line = town_name. = (NAMMOTH) {
System.out.println("Town Found");
}
}
catch( IOException e )
{
System.err.println("IO Exception");
System.exit(1);
}
}
}
I've done the hard part of the question but i'm stuttering on the construction of a class that will enable users to enter towns in the command prompt and all details for that particular town pop up.
I've done the following , and forgive i've changed the codes so many times because i'm constantly getting errors and hence it looks a bit messy, someone fresh needs to have a look.
Just to remind the format for each town is eg NAMMOTH:NM:280520:-10550:4
Nammoth being the town, NM(county code),280520 lat,10550 lon, 440km (east coord) and 464km (north coord).
please feel free to ask me further ? , if u don't understand my ?, i can hardly understand it myself.
THANK YOU
import java.io.*;
public class Distances
{
public static void main(String[] args)
{
try
{
BufferedReader in = new BufferedReader(new FileReader("towns.txt"));
String str;
while ((str = in.readLine()) != null) {
towns.add(new Town(str));
{
int town_name;
if line = town_name. = (NAMMOTH) {
System.out.println("Town Found");
}
}
catch( IOException e )
{
System.err.println("IO Exception");
System.exit(1);
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks guys i'll try all your suggested solutions.
I'll give more feedback in a bit, but please let me know if you've got any addditions to make to the above comments.
I'll give more feedback in a bit, but please let me know if you've got any addditions to make to the above comments.
ASKER
import java.io.*;
public class cities
{
public static void main(String[] args)
{
try
{
FileReader file=new FileReader("towns.txt");
BufferedReader buffer=new BufferedReader(file);
int town_name;
String town = "NAMMOTH:NM:280520:-10550:
if line==town_name.=(NAMMOTH)
{
System.out.println("Town Found");
}
try
{
while((textline = buffer.readLine()) !=null)
System.out.println(textlin
buffer.close();
}
catch( IOException e )
{
System.err.println("IO Exception");
System.exit(1);
}
catch(FileNotFoundExceptio
{
System.out.println("Couldn
System.out.println(":" + fnex.getMessage());
System.exit(1);
}
}
}