Hi
this is the question:
In airlines reservation systems "dan jeddah" command is used to get the airport code for Jeddah city.
Design and implement a java code that simulate the "dan" command.
Use the following file as a dataset:
I can't put the link:confused:
Use contains method in String class to look up the city and return the city code.
e.g. dan Jeddah returns JED
and I wrote this code
any suggestion will help me:)Code:import java.io.*;
import java.util.*;
public class Dan{
public static void main (String[] args){
Scanner input= null;
try{
input = new Scanner(new File("C:\\Users\\Lost Spirit\\Desktop\\iata-airport-codes.txt"));
}
catch(FileNotFoundException e){
System.out.println("not found the file");
System.exit(0);
}
Scanner h= new Scanner(System.in);
String we= h.nextLine();
String line= null, er= null;
int qwe;
while (input.hasNextLine()){
line= input.nextLine();
qwe= line.indexOf(we);
er= line.substring((qwe-4),(qwe-1));
}
input.close();
System.out.println(qwe);
}
}
