The volleyball coach at Verde Valley High School would like some help managing her team. She is looking for a piece of software to help her see who her best players are, and build scrimmage teams that are well balanced. She has a team roster stored in a text file that contains the names of her players (first name, then last name separated by a space), and their stats as attacks per set (double) followed by blocks per set (double). Higher stats are better. Each data field is separated by a space. For example, one line would look like:
Gabrielle Reece 4.57 1.79
DIRECTIONS
The coach would like the program to do the following:
Present a menu with the following options:
1) Open a roster
2) List top 3 attackers
3) List top 3 blockers
4) Make and display scrimmage teams
5) Quit
If the user chooses 1) Open a roster, then the program should ask for the filename of the roster, then read the data from that file into an array.
If the user chooses 2) List top 3 attackers, then the program should determine and list the names and stats of the players with the top 3 attack stats.
If the user tries to list the top attackers without first opening a roster file, then the program should respond with the error message "Please open a roster."
If the user chooses 3) List top 3 blockers, then the program should determine and list the names and stats of the players with the top 3 stats for blocks.
If the user tries to list the top blockers without first opening a roster file, then the program should respond with the error message "Please open a roster."
If the user chooses 4) Make and display scrimmage teams, then the program should divide the roster into 6-person scrimmage teams, and display the list of players on each team.
If the user tries to make and display scrimmage teams without first opening a roster file, then the program should respond with the error message "Please open a roster."
Your program will need to be able to divide a roster into the maximum possible number of teams. For example, a roster with 18 players on it would be divided up into three different scrimmage teams with six players each. A roster file will always contain a list of between 12 and 25 players, and a scrimmage team always has six players.
The coach would like the teams to be reasonably well balanced. To do this, your program should make up half of each scrimmage team by distributing the best attackers to each of the different teams. For example, a roster with 12 players on it would be divided up into two scrimmage teams, and three of the top six attackers would be assigned to each of the two scrimmage teams. After the top attackers have been assigned to make up half of each scrimmage team, then the top blockers (from the remaining unassigned players) would similarly be assigned (three to each scrimmage team in this example) to make up the other half of each team.
As a more detailed example, consider the following roster:
|
Name |
Attack Stat |
Blocking Stat |
|
Rachael Adams |
3.36 |
1.93 |
|
Foluke Akinradewo |
4.81 |
1.14 |
|
Kayla Banwarth |
2.98 |
0.50 |
|
Michelle Bartsch |
0.28 |
1.42 |
|
Krista Vansant |
2.78 |
0.86 |
|
Courtney Thompson |
0.59 |
0.93 |
|
Kelly Murphy |
1.15 |
0.58 |
|
Lauren Gibbemeyer |
2.25 |
0.50 |
|
Alexis Crimes |
3.89 |
1.34 |
|
Tori Dixon |
0.92 |
1.62 |
|
Nicole Fawcett |
4.01 |
0.61 |
|
Alisha Glass |
1.96 |
1.55 |
|
Natalie Hagglund |
2.49 |
0.52 |
|
Kim Hill |
1.53 |
1.76 |
|
Cursty Jackson |
0.69 |
1.44 |
Given the above roster with 15 players, your program should make and display the follow two scrimmage teams:
Team 1:
Foluke Akinradewo
Alexis Crimes
Kayla Banwarth
Kim Hill
Alisha Glass
Michelle Bartsch
Team 2:
Nicole Fawcett
Rachael Adams
Krista Vansant
Tori Dixon
Cursty Jackson
Courtney Thompson
If the user chooses 5) Quit, then the program should exit.
Things to think about when you’re designing and writing this program:
IF YOU HAVE ANY DOUBTS COMMENT BELOW I WILL BE THERE TO HELP YOU
ANSWER:
CODE:
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.stream.Collectors;
public class TeamSelection {
public static void main(String[] args) throws FileNotFoundException {
int choice =0;
Scanner scan = new Scanner(System.in);
Map<String,Float> blockers=new HashMap<String,Float>();
Map<String,Float> attackers=new HashMap<String,Float>();
LinkedHashMap<String, Float> sortedblockers=new LinkedHashMap<String, Float>();
LinkedHashMap<String, Float> sortedAttackers=new LinkedHashMap<String, Float>();
int cout=0;
ArrayList<String> team1=new ArrayList<String>();
ArrayList<String> team2=new ArrayList<String>();
ArrayList<String> team3=new ArrayList<String>();
ArrayList<String> team4=new ArrayList<String>();
System.out.println("1.Open a roster\n2.List top 3 attackers\n3.List top 3 blockers\n4.make and display scrimmage Teams\n5.Exit");
do{
System.out.println("Enter your choice:");
choice=scan.nextInt();
int i=1;
switch(choice){
case 1:
//for reading
File file = new File("D:\\roster.txt");
Scanner sc = new Scanner(file);
while(sc.hasNextLine()){
if(cout==0){
cout++;
sc.nextLine();
continue;
}
cout++;
String data[]=sc.nextLine().split("\t");
blockers.put(data[0], Float.parseFloat(data[2]));
attackers.put(data[0], Float.parseFloat(data[1]));
sortedblockers=blockers.entrySet().stream().sorted(Collections.reverseOrder(Map.Entry.comparingByValue()))
.collect(Collectors.toMap( Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
sortedAttackers=attackers.entrySet().stream().sorted(Collections.reverseOrder(Map.Entry.comparingByValue()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
}
break;
case 2:
i=1;
if(cout>1){
System.out.println("Top 3 Attackers");
for(Entry<String, Float> e : sortedAttackers.entrySet()) {
if(i==4){
break;
}
System.out.println(i+"."+e.getKey());
i++;
}}else{
System.out.println("Please open a roster");
}
break;
case 3:
i=1;
if(cout>1){
System.out.println("Top 3 Blockers");
for(Entry<String, Float> e : sortedblockers.entrySet()) {
if(i==4){
break;
}
System.out.println(i+"."+e.getKey());
i++;
}}else{
System.out.println("Please open a roster");
}
break;
case 4:
ArrayList<String> selected=new ArrayList<String>();
i=1;
if(cout/6==2){
for(Entry<String, Float> e : sortedAttackers.entrySet()) {
if(i==7){
break;
}
if(i%2==0){
team2.add(e.getKey());
selected.add(e.getKey());
}else{
team1.add(e.getKey());
selected.add(e.getKey());
}
i++;
}
i=1;
for(Entry<String, Float> e : sortedblockers.entrySet()) {
boolean flag=false;
if(i==7){
break;
}
for(String temp:selected){
if(temp.equalsIgnoreCase(e.getKey())){
flag=true;
break;
}
}
if(flag){
continue;
}
if(i%2==0){
team2.add(e.getKey());
selected.add(e.getKey());
}else{
team1.add(e.getKey());
selected.add(e.getKey());
}
i++;
}
System.out.println("Team1");
for(String temp:team1){
System.out.println(temp);
}
System.out.println("Team2");
for(String temp:team2){
System.out.println(temp);
}
}
if(cout/6==3){
for(Entry<String, Float> e : sortedAttackers.entrySet()) {
if(i==10){
break;
}
if(i%3==0){
team3.add(e.getKey());
selected.add(e.getKey());
}else if(i%3==1){
team1.add(e.getKey());
selected.add(e.getKey());
}else if(i%3==2){
team2.add(e.getKey());
selected.add(e.getKey());
}
i++;
}
i=1;
for(Entry<String, Float> e : sortedblockers.entrySet()) {
boolean flag=false;
if(i==10){
break;
}
for(String temp:selected){
if(temp.equalsIgnoreCase(e.getKey())){
flag=true;
break;
}
}
if(flag){
continue;
}
if(i%3==0){
team3.add(e.getKey());
selected.add(e.getKey());
}else if(i%3==1){
team1.add(e.getKey());
selected.add(e.getKey());
}else if(i%3==2){
team2.add(e.getKey());
selected.add(e.getKey());
}
i++;
}
System.out.println("Team1");
for(String temp:team1){
System.out.println(temp);
}
System.out.println("Team2");
for(String temp:team2){
System.out.println(temp);
}
System.out.println("Team3");
for(String temp:team3){
System.out.println(temp);
}
}
if(cout/6==4){
for(Entry<String, Float> e : sortedAttackers.entrySet()) {
if(i==13){
break;
}
if(i%4==0){
team4.add(e.getKey());
selected.add(e.getKey());
}else if(i%3==1){
team1.add(e.getKey());
selected.add(e.getKey());
}else if(i%3==2){
team2.add(e.getKey());
selected.add(e.getKey());
}else if(i%4==3){
team3.add(e.getKey());
selected.add(e.getKey());
}
i++;
}
i=1;
for(Entry<String, Float> e : sortedblockers.entrySet()) {
boolean flag=false;
if(i==13){
break;
}
for(String temp:selected){
if(temp.equalsIgnoreCase(e.getKey())){
flag=true;
break;
}
}
if(flag){
continue;
}
if(i%4==0){
team4.add(e.getKey());
selected.add(e.getKey());
}else if(i%4==1){
team1.add(e.getKey());
selected.add(e.getKey());
}else if(i%4==2){
team2.add(e.getKey());
selected.add(e.getKey());
}else if(i%4==3){
team3.add(e.getKey());
selected.add(e.getKey());
}
i++;
}
System.out.println("Team1");
for(String temp:team1){
System.out.println(temp);
}
System.out.println("Team2");
for(String temp:team2){
System.out.println(temp);
}
System.out.println("Team3");
for(String temp:team3){
System.out.println(temp);
}
System.out.println("Team4");
for(String temp:team4){
System.out.println(temp);
}
}
break;
}
}while(choice!=5);
}
}
HOPE IT HELPS YOU
RATE THUMBSUP PLEASE
The volleyball coach at Verde Valley High School would like some help managing her team. She...
C++ Language Overview: Design an APP for a basketball team with a unique name. There should be at least 10 players. The member variables required include team member’s names, jersey number, position played, and at least 3 stats. Positions are small forward, power forward, center, shooting guard and point guard. 1. A.) Design a class with member variables and appropriate member functions Data should be stored in a read/write file consisting of team member’s names, jersey number, position played, and...
using microsoft visuals studio c# 2017 Your "goal" is to create a soccer team registration program. This is an individual assignment. Your program should: 1. Ask the coach to select a team from a list (maybe listbox or radio buttons). 1. Accept athlete names from the "coach". There can be up to twelve athletes on a team. You can do this many ways, for example, have twelve textboxes to accept the information. However, after you received the information from the...
I need to update this C++ code according to these instructions.
The team name should be "Scooterbacks".
I appreciate any help!
Here is my code:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void menu();
int loadFile(string file,string names[],int jNo[],string
pos[],int scores[]);
string lowestScorer(string names[],int scores[],int size);
string highestScorer(string names[],int scores[],int size);
void searchByName(string names[],int jNo[],string pos[],int
scores[],int size);
int totalPoints(int scores[],int size);
void sortByName(string names[],int jNo[],string pos[],int
scores[],int size);
void displayToScreen(string names[],int jNo[],string pos[],int
scores[],int size);
void writeToFile(string...
Write a java netbeans program. Project Two, Super Bowl A text file named “SuperBowlWinners.txt” contains the names of the teams that won the Super Bowl from 1967 through 2019. Write a program that repeatedly allows a user to enter a team name and then displays the number of times and the years in which that team won the Super Bowl. If the team entered by the user has never won the Super Bowl, report that to the user instead. For...
Chapter 8
Python Case study Baseball Team Manager
For this case study,
you’ll use the programming skills that you learn in Murach’s
Python Programming to develop a program that helps a
person manage a baseball team. This program stores the data for
each player on the team, and it also lets the manager set a
starting lineup for each game. After you read chapter 2, you can
develop a simple program that calculates the batting average for a
player. Then,...
For Python-3 I need help with First creating a text file named "items.txt" that has the following data in this order: Potatoes Tomatoes Carrots. Write a python program that 1. Puts this as the first line... import os 2. Creates an empty list 3. Defines main() function that performs the tasks listed below when called. 4. Put these two lines at the top of the main function... if os.path.exists("costlist.txt"): os.remove("costlist.txt") Note: This removes the "costlist.txt" file, if it exists. 5....
Case Study Baseball Team Manager For this case study, you’ll use the programming skills that you learn in Murach’s Python Programming to develop a program that helps a person manage a baseball team. This program stores the data for each player on the team, and it also lets the manager set a starting lineup for each game. After you read chapter 2, you can develop a simple program that calculates the batting average for a player. Then, after you complete...
NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...
NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...
PLEASE INCLUDE SAW-PROMPTS FOR 2 PLAYERS NAMES(VALIDATE NAMES). SHOW MENU (PLAYER MUST SELECT FROM MENU B4 THE GAME STARTS 1=PLAY GAME, 2=SHOW GAME RULES, 3=SHOW PLAYER STATISTICS, AND 4=EXIT GAME WITH A GOODBYE MESSAGE.) PLAYERS NEED OPTION TO SHOW STATS(IN A DIFFERNT WINDOW-FOR OPTION 3)-GAME SHOULD BE rock, paper, scissor and SAW!! PLEASE USE A JAVA GRAPHICAL USER INTERFACE. MUST HAVE ROCK, PAPER, SCISSORS, AND SAW PLEASE This project requires students to create a design for a “Rock, Paper, Scissors,...