Question

I need help programming the main args. I am notimport java.util.ArrayList; import java.util.Scanner; public class Fantasy Football public static void main(string] args) Arr sure what to do after I create an array list and scanner.Create a program that allows you to create a fantasy football roster based on the existing list of available players. Your teh

1 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #0

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

Add a comment
Know the answer?
Add Answer to:
I need help programming the main args. I am not sure what to do after I...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Java 7.17 Clone of LAB*: Program: Soccer team roster This program will store roster and rating...

    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...

    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...

    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...

  • 5.22 LAB*: Program: Soccer team roster steam This program will store roster and rating information for...

    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...

    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...

    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 w...

    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...

  • I am currently using eclipse to write in java. A snapshot of the output would be...

    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...

  • Can someone help me with my code.. I cant get an output. It says I do...

    Can someone help me with my code.. I cant get an output. It says I do not have a main method. HELP PLEASE. The instruction are in bold on the bottom of the code. package SteppingStones; //Denisse.Carbo import java.util.Scanner; import java.util.ArrayList; import java.util.List; public class SteppingStone5_Recipe { private String recipeName; private int servings; private List<String> recipeIngredients; private double totalRecipeCalories; public String getRecipeName() { return recipeName; } public void setRecipeName (string recipeName){ this.recipeName = recipeName; } public int getServings() { return...

  • I need help writing my main method**** Computer Science 111 Introduction to Algorithms and Programming: Java...

    I need help writing my main method**** Computer Science 111 Introduction to Algorithms and Programming: Java Programming Project #4 – Classes and Objects (20 Points) You will create 3 new classes for this project, two will be chosen from the list below and one will be an entirely new class you invent.Here is the list: Shirt Shoe Wine Book Song Bicycle VideoGame Plant Car FootBall Boat Computer WebSite Movie Beer Pants TVShow MotorCycle Design First Create three (3) UML diagrams...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT