Netbeans:Java Write this code. : well documented please. Text file name to be us
ID: 3667124 • Letter: N
Question
Netbeans:Java Write this code. : well documented please. Text file name to be used: Statedata.txt
last programming assignment:
Your task is to create software similar to the last programming assignment implementing a list of states, but the list should be implemented using a linked list instead of an array. This project will require a new StateList class which uses a linked list instead of an array, and a new class for a ListNode If properly implemented, you should not need to change the project class - it should work with a list class whether that list is implemented with an array or a linked list. The internal details of the data structure should not affect the user's view of operations from outside the data structure. In other words our classes should be encapsulated, so a StateList class has methods that define the user's view of the class. Those methods should provide the same functionality to the user no matter what the internal mechanisms of the methods are. That functionality is defined by the method's name and parameters, its returned values, and any messages it prints The main method should simply call the other methods in the class to show that they work Each class should be in its own file, within the same package in the same NetBeans project, just as in the previous assignmentExplanation / Answer
Hi,
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.LinkedList;
import java.util.Scanner;
public class LinkedLocation {
public static void main(String args[]){
String name;
String cap;
String popltn;
LinkedList<String> list=new LinkedList<String>();
try{
File ff=new File("C://Users//Infomite//Desktop//Statedata.txt");
Scanner snr=new Scanner(ff);
int cnt=0;
while(snr.hasNext()){
//System.out.println(snr.next());
//cnt++;
list.add(snr.next());
}
System.out.println(" State Capital Population ");
System.out.println("----------------------------------------------");
for(int i=0;i<list.size();i=i+3){
System.out.println(" "+list.get(i)+" "+list.get(i+1)+" "+list.get(i+2)+" ");
}
System.out.println("Enter State name");
name=snr.next();
if(!list.contains(name)){
System.out.println("State not found");
}
}catch(Exception e ){
e.printStackTrace();
}
}
}