Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Scanner library showing element not found exception

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
Comment

PREVIOUS NEXT
Code Example
Java :: Java Shuffling Using shuffle() 
Java :: has 8 digit in number 
Java :: java lambda expressions qunado foi implantada 
Java :: hello world in bukkit 
Java :: JDA send DM 
Java :: seekbar thumb position 
Java :: extracting kubernetes podname from java 
Java :: java webelement how to double click 
Java :: java.lang.stackoverflowerror null onetomany 
Java :: Error: Unable to export or encrypt the private key java.lang.NullPointerException 
Java :: ring write a character to the stream 
Java :: create a class 
Java :: who was the mother of thomas elva edison 
Java :: https://javahungry.blogspot.com/2020/01/list-of-lists-in-java.html 
Java :: how to read space separated characters in java 
Java :: spring code in java 
Java :: Write a java program to print the ip address 
Java :: sibling search java program 
Java :: java find view by id 
Java :: bebra 
Java :: Sample TreeMap 
Java :: store files system in tree java 
Java :: jframe open another frame using button actionlistener 
Java :: reference value in array list java syntax 
Java :: Note: C:flutter..path_provider_android-2.0.11androidsrcmainjavaioflutterpluginspathproviderPathProviderPlugin.java uses unchecked or unsafe operations 
Java :: what does the continue keyword do in java 
Java :: Algorithms - Max value 
Java :: does java recognize on a txt file 
Java :: JAXRS EXCEPTION MAPPER 
Java :: java add xmlns attribute 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =