I need help programming the main args. I am not
sure what to do after I
create an array list and scanner.
h
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
=================================
// FantasyFootball.java
import java.util.ArrayList;
import java.util.Scanner;
public class FantasyFootball {
public static void main(String[] args) {
ArrayList<String> availablePlayers=new
ArrayList<String>();
addPlayers(availablePlayers);
String roster[];
roster=new String[5];
/*
* Creating an Scanner class object
which is used to get the inputs
* entered by the user
*/
Scanner sc = new
Scanner(System.in);
for(int
i=0;i<roster.length;)
{
//Getting the input entered by the
user
System.out.print("\nEnter Player would you like on your team
:");
String player=sc.nextLine();
if(search(availablePlayers,player)==-1)
{
System.out.println("That Player is not available,
please pick another player.");
}
else
{
roster[i]=player;
System.out.println("Great! That player is added to
your team!");
i++;
}
}
System.out.println("\nYour team is
:");
for(int
i=0;i<roster.length;i++)
{
System.out.println(roster[i]);
}
}
private static int search(ArrayList<String>
availablePlayers, String player) {
for(int
i=0;i<availablePlayers.size();i++)
{
if(availablePlayers.get(i).equalsIgnoreCase(player))
return i;
}
return -1;
}
private static void
addPlayers(ArrayList<String> array) {
array.add("Can Newton");
array.add("Antonio Brown");
array.add("Leveon Bell");
array.add("Patrick Mohomes");
array.add("Saquon Barkley");
array.add("Mike Evans");
array.add("Odell Beckham
Jr.");
array.add("Travis Keice");
array.add("Baker MayField");
array.add("Micheal Thomas");
array.add("Julio Jones");
array.add("Ezekial Eiliott");
array.add("Alwin Kamara");
array.add("Davanta Adams");
array.add("Aaron Rogers");
}
}
=================================
Enter Player would you like on your team :Mike
Evans
Great! That player is added to your team!
Enter Player would you like on your team :Julio
Jones
Great! That player is added to your team!
Enter Player would you like on your team :Aaron
Rogers
Great! That player is added to your team!
Enter Player would you like on your team :Kane
Williams
That Player is not available, please pick another
player.
Enter Player would you like on your team :Leveon
Bell
Great! That player is added to your team!
Enter Player would you like on your team :Can
Newton
Great! That player is added to your team!
Your team is :
Mike Evans
Julio Jones
Aaron Rogers
Leveon Bell
Can Newton
=====================Could you plz rate me
well.Thank You
I need help programming the main args. I am not sure what to do after I...
Java
7.17 Clone of LAB*: Program: Soccer team roster This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team. (1) Prompt the user to input five pairs of numbers: A player's jersey number (0-99, but this is NOT enforced by the program nor tested) and the player's rating (1-9, not enforced like jersey numbers). Store the jersey numbers in one int array and the ratings in another int...
can someone please help me with my computer science homework. i
am not sure if i am doing it correctly i would like your answer so
i can compare with mine
Create an ArrayList with the below state codes in it. AL AK AZ AR CA TX MA Once the ArrayList is created do below operations 1. Add the state PA in the ArrayList at the end 2. Search through the ArrayList and replace the state CA with FL 3....
I need help with this code This is what I need to do: Implement the Stack Class with an ArrayList instead of an array, including the following functions: • empty • push • peek • pop • overrided toString( ) function which returns all of the stack’s contents Things to note: • You no longer need a size. • You no longer need to define a constant DEFAULT_CAPACITY. Since ArrayLists grow dynamically. • Whenever possible, use ArrayList functions instead of...
Need some help on homework practice problems, Thank you in advance! Problem 1: Write a method, parallelSum(), that uses the fork-join framework to compute the sum of the elements of an array. Its skeleton as well as its Javadoc is provided in the file ParallelSum.java. Simple code for testing and timing your method is also provided in the main method. This problem is essentially the same as ParallelMax in structure. Therefore, follow the code for ParallelMax to complete ParallelSum. Problem...
5.22 LAB*: Program: Soccer team roster steam This program will store roster and rating information for a soccer team Coaches rate players during tryouts to ensure (1) Prompt the user to input five pairs of numbers: A player's jersey number (0.99) and the player's rating (1-9) Store in one int array and the ratings in another int array Output these arrays (e. output the roster) (3 pts) numbers EX Enter player 1 jersey number: Enter player l's rating: Enter player...
I am creating a program that will allow users to sign in with a username and password. Their information is saved in a text file. The information in the text file is saved as such: Username Password I have created a method that will take the text file and convert into an array list. Once the username and password is found, it will be removed from the arraylist and will give the user an opportunity to sign in with a...
5.19 Lab 11b: Soccer team roster Instructor note: NOTE Unlike our other assignments, this one has only two programs: People's Weights and this one. To earn 30 points, you must do both assignments. Allow ample time to complete them Passing arrays to methods Review Chapter 6.8 Array Parameters if you wish to use methods in your program (a good idea). Since we pass a reference to the array's location in memory, changes made to the array within the method will...
In C Program This program will store the roster and rating information for a soccer team. There will be 3 pieces of information about each player: Name: string, 1-100 characters (nickname or first name only, NO SPACES) Jersey Number: integer, 1-99 (these must be unique) Rating: double, 0.0-100.0 You must create a struct called "playData" to hold all the information defined above for a single player. You must use an array of your structs to to store this information. You...
Please help me finish my code. Before the final pause in the main function, create an ArrayList of another type such as double, char, short, bool, float, etc. Your choice. Add five data items to your array as we did for the int and string array lists. Print them out with a for loop as we did before. Print out the count and capacity of your new array list. Source.cpp #include #include #include #include "ArrayList.h" using namespace std; /// Entry...
I am currently using eclipse to write in java.
A snapshot of the output would be greatly appreciated to verify
that the program is indeed working. Thanks in advance for both your
time and effort.
Here is the previous exercise code:
/////////////////////////////////////////////////////Main
/*******************************************
* Week 5 lab - exercise 1 and exercise 2: *
* ArrayList class with search algorithms *
********************************************/
import java.util.*;
/**
* Class to test sequential search, sorted search, and binary search
algorithms
* implemented in...