Scanner library showing element not found exception
Java
import java.util.ArrayList;
import java.util.Collections;
import java.lang.Object;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Bracket_Creator{
public static void main(String[] args) throws FileNotFoundException
{
String first_name = "";
String last_name = "";
String school = "";
int weight = 0;
int confer_win = 0;
int confer_loss = 0;
int overall_wins = 0;
int overall_loss = 0;
ArrayList<Wrestler> list = new ArrayList<Wrestler>();
int i = 0;
boolean flag = true;
//new scanner instance
Scanner scanner = new Scanner(new File("wrestlers.csv"));
//the seperator for the file
scanner.useDelimiter(",");
while(scanner.hasNext()){
first_name = scanner.next();
last_name = scanner.next();
school = scanner.next();
weight = scanner.nextInt();
confer_win = scanner.nextInt();
confer_loss = scanner.nextInt();
overall_wins = scanner.nextInt();
overall_loss = scanner.nextInt();
list.add(new Wrestler(first_name,last_name,school,weight,
confer_win,confer_loss,overall_wins,overall_loss));
System.out.println((list.get(i).get_first_name()));
i++;
}//end while
scanner.close();
//make the percentages for the wrestlers
for (i = 0; i < list.size(); i++){
(list.get(i)).determine_conf_percentage((list.get(i)).get_confer_wins(), (list.get(i)).get_confer_losses());
(list.get(i)).determine_overall_percentage((list.get(i)).get_overall_wins(), (list.get(i)).get_overall_losses());
}//end for loop
//set rank
while ( flag )
{
flag= false; //set flag to false awaiting a possible swap
for( i=0; i < list.size() -1; i++ )
{
if ((list.get(i)).get_confer_percentage() < (list.get(i+1)).get_confer_percentage() )
{
Collections.swap(list, i, i+1);
flag = true;
}//end if
}//end for
}//end while
//set rank value
for (i = 0; i< list.size(); i++){
(list.get(i)).set_rank(i + 1);
}//end for loop
for (i = 0; i< list.size(); i++){
System.out.println((list.get(i)).get_first_name());
}
System.out.println("");
/*
*
*
*Create the Bracket!
*
*
*/
int j = 1; //J here is for the end of the list, every time you go through
//add one to J in the loop to keep on coming in from the other end of
//the list
for (i = 0; i< (list.size()/2); i++){
if (i == 0) {//first pass thru the list
System.out.println((list.get(i)).get_first_name());
System.out.println((list.get(list.size()-j)).get_first_name());
System.out.println();
j++;
}//end if
else{
System.out.println((list.get(i)).get_first_name());
System.out.println((list.get(list.size()-j)).get_first_name());
System.out.println();
j++;
}//end else
}//end for
}//end main
}//end bracket_creator class
Also in Java:
- Title
- java function that returns the index of the largest value in an array
- Category
- Java
- Title
- java resultset to table
- Category
- Java
- Title
- check if map contains key java
- Category
- Java
- Title
- java cast duration to long
- Category
- Java
- Title
- string method example in java
- Category
- Java
- Title
- how to implement a interface in java
- Category
- Java
- Title
- multiplication program java
- Category
- Java
- Title
- on click android studio not working
- Category
- Java
- Title
- create jdbc connection in java
- Category
- Java
- Title
- java console write
- Category
- Java
- Title
- how to read file from assets folder in android
- Category
- Java
- Title
- java math.random
- Category
- Java
- Title
- java literals w3schools
- Category
- Java
- Title
- java question mark operator
- Category
- Java
- Title
- decomposer chaine de caractère java
- Category
- Java
- Title
- spannable string in android java for color
- Category
- Java
- Title
- find duplicate elements in array in java
- Category
- Java
- Title
- exponents java
- Category
- Java
- Title
- java == vs equals
- Category
- Java
- Title
- phoneword converter
- Category
- Java
- Title
- java loop through string
- Category
- Java
- Title
- Java create array of array
- Category
- Java
- Title
- open an existing excel file in java apache poi
- Category
- Java
- Title
- déclarer un tableau en java
- Category
- Java
- Title
- how to read to into a file in java
- Category
- Java
- Title
- java create a set with values
- Category
- Java
- Title
- java read integer from text file into array scanner
- Category
- Java
- Title
- 2 decimal places print format JAVA
- Category
- Java
- Title
- add two numbers bitwise
- Category
- Java
- Title
- get today date in java 8
- Category
- Java
- Title
- how to add a keylistener to a jframe
- Category
- Java
- Title
- how to add multiple filter condition in Java stream filter chain
- Category
- Java
- Title
- how to exit a for loop in java
- Category
- Java
- Title
- change the value in a hashtable java
- Category
- Java
- Title
- BoxLayout java
- Category
- Java
- Title
- map.keyset in java
- Category
- Java
- Title
- string to arraylist convert java
- Category
- Java
- Title
- array null pointer java
- Category
- Java
- Title
- if and in java
- Category
- Java
- Title
- prime number program in java
- Category
- Java
- Title
- java execute jar from main
- Category
- Java
- Title
- capitalize string java
- Category
- Java
- Title
- how to crate a list in java script
- Category
- Java
- Title
- how to get the max value of an array java
- Category
- Java
- Title
- osmdroid offline map does not show
- Category
- Java
- Title
- java thread
- Category
- Java
- Title
- java permutation
- Category
- Java
- Title
- how to send http post create request using curl command
- Category
- Java
- Title
- how to run java program in linux server
- Category
- Java
- Title
- java Convert a string IPv4 IP address to the equivalent long numeric value.
- Category
- Java
- Title
- how to know when user is done typing android
- Category
- Java
- Title
- math maximum java
- Category
- Java
- Title
- Fab to CircularRevealFrameLayout example
- Category
- Java
- Title
- how to install java 8 in ubuntu 16.04
- Category
- Java
- Title
- linux command to see all the java version installed
- Category
- Java
- Title
- java 8 validate based on pair of strings
- Category
- Java
- Title
- java public static void main
- Category
- Java
- Title
- system.in example in java
- Category
- Java
- Title
- how to add element to arraylist
- Category
- Java
- Title
- java script how to not allow soace
- Category
- Java
- Title
- for next loop javasxcrop
- Category
- Java
- Title
- labeled for loop in java
- Category
- Java
- Title
- how do i print text in java
- Category
- Java
- Title
- Manifest merger failed androidx
- Category
- Java
- Title
- read a file in java and store as integer array using buffered reader
- Category
- Java
- Title
- how to print in java
- Category
- Java
- Title
- how to remove all items from alist in java
- Category
- Java
- Title
- java xml element get attribute value
- Category
- Java
- Title
- stack class in java
- Category
- Java
- Title
- java random number
- Category
- Java
- Title
- how to declare array java
- Category
- Java
- Title
- creating the functional interface in java
- Category
- Java
- Title
- how to select a element in an arraylist java
- Category
- Java
- Title
- method resolve file in java
- Category
- Java
- Title
- hibernate Unknown integral data type for ids : java.lang.String
- Category
- Java
- Title
- how to make int array java android
- Category
- Java
- Title
- dates in java 8
- Category
- Java
- Title
- how to print each element of an arraylist on a new line in java
- Category
- Java
- Title
- java array check duplicates
- Category
- Java
- Title
- math min max java
- Category
- Java
- Title
- fibonacci sequence java using recursion
- Category
- Java
- Title
- how to read a csv file java
- Category
- Java
- Title
- could not initialize defaultkotlinsourcesetkt intelij
- Category
- Java
- Title
- java scanner input int
- Category
- Java
- Title
- usaco 2018 january contest
- Category
- Java
- Title
- jbutton remove selection border
- Category
- Java
- Title
- java clone method
- Category
- Java
- Title
- java stream sort Collator
- Category
- Java
- Title
- lightweight java game library
- Category
- Java
- Title
- how to change the icon of a jframe
- Category
- Java
- Title
- java find biggest number in array
- Category
- Java
- Title
- java read each lines in file
- Category
- Java
- Title
- color from hex code flutter
- Category
- Java
- Title
- java clear console
- Category
- Java
- Title
- checking if a given integer is a prime number java
- Category
- Java
- Title
- java sort array descending
- Category
- Java
- Title
- processing sound library
- Category
- Java
- Title
- how to make a new arraylist java
- Category
- Java
- Title
- spigot kill entity
- Category
- Java
- Title
- java switch
- Category
- Java