I\'ve already created the classes asked in the last two pictures(in JAVA), I\'ve
ID: 3675198 • Letter: I
Question
I've already created the classes asked in the last two pictures(in JAVA), I've only attached them to assist with any confusion. (GeoLocation and CTAStation) are done. I simply need help creating the CTAStopApp which would read in from an excel, csv file.
Problem:
References :
Csv file looks like this, w/ station information
Please help in writing the application class (CTAStopApp)
CTAStopApp As mentioned earlier, this app will display a menu of options of which data to extract from the data stored in the CTAStationl. The API for this app class is as below: You do not need to follow this API but it may help you to figure out how to break down the tasks . main . reads station input file and stores the data in an instance of CTAStationl] displays the menu options, which should be the following Display Station Names Display Stations with/without Wheelchair AccessExplanation / Answer
import java.io.*;
import java.util.*;
class CTAStation{
String name;
String location;
boolean opened;
double latitude ;
double longitude;
boolean wheelchair;
public CTAStation(String name,String location,boolean opened,double latitude,double longitude,boolean wheelchair){
this.name = name;
this.location = location;
this.opened = opened;
this.latitude = latitude;
this.longitude = longitude;
this.wheelchair = wheelchair;
}
double calcDistance(CTAStation ct){
}
double calcDistance(double d_1,double d_2){
}
}
class main{
public static CTAStation[] cta_station = new CTAStation[27];
public static void displayStationNames(){
System.out.println("--------- STATION NAMES ---------");
for (int i = 0; i < cta_station.length; i++)
System.out.println(cta_station[i].name);
}
public static void displaybyWheelchair(char ch){
if (ch == 'y' || ch == 'Y'){
System.out.println("--------- STATION WITH WHEEL CHAIR ACCESSIBILITY ---------");
boolean check = false;
for (int i = 0; i < cta_station.length; i++){
if (cta_station[i].wheelchair == true){
System.out.println(cta_station[i].name);
check = true;
}
}
}
else{
System.out.println("--------- STATION WITHOUT WHEEL CHAIR ACCESSIBILITY ---------");
boolean check = false;
for (int i = 0; i < cta_station.length; i++){
if (cta_station[i].wheelchair == false){
System.out.println(cta_station[i].name);
check = true;
}
}
}
if (check == false)
System.out.println("NO SUCH STATION FOUNR !!!!!");
}
public static void main(String[] args){
BufferedReader br = null;
// Reading data from file
try{
br = new BufferedReader(new FileReader("input.csv"))
int i = 0;
while ((line = br.readLine()) != null) {
// use comma as separator
String[] temp = line.split(',');
String name = temp[0];
String location = temp[3];
boolean opened = (temp[4].compareTo("TRUE") == 0) ? true : false;
double latitude = Double.parseDouble(temp[1]);
double longitude = Double.parseDouble(temp[2]);
boolean wheelchair = (temp[5].compareTo("TRUE") == 0) ? true : false;
CTAStation ct = new CTAStation(name,location,opened,latitude,longitude,wheelchair);
cta_station[i] = ct;
i += 1;
}
// Diplay Menu option
Scanner sc = new Scanner(System.in);
while (true){
System.out.println("1. Display Station Names");
System.out.println("2. Display Station with/without Wheelchair Access");
System.out.println("3. Display the Distance to Each Station");
System.out.println("4. Exit");
int n = sc.nextInt();
if (n == 1)
displayStationNames();
else if (n == 2){
System.out.print("Enter accessibility (y or n only) : ");
char ch = sc.next().charAt(0);
while (ch != 'Y' || ch != 'y' || ch != 'n' || ch != 'N'){
System.out.print("Enter accessibility (y or n only) : ");
ch = sc.next().charAt(0);
}
displaybyWheelchair(ch);
}
else if (n == 3){
}
else
break;
}
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}
}