Question

In: Computer Science

Write a complete program in java that will do the following:

Write a complete program in java that will do the following:

Sports:             Baseball, Basketball, Football, Hockey, Volleyball, Waterpolo

Players:           9, 5, 11, 6, 6, 7

  • Store the data in appropriate arrays

  • Provide an output of sports and player numbers. See below:

Baseball          9 players.

Basketball       5 players.

Football           11 players.

Hockey            6 players.

Volleyball        6 players.

Waterpolo       7 players.

  • Use Scanner to provide the number of friends you have for a team sport.

  • Provide an output of suggested sports for your group of friends. If your group is 6 people, see the example below:

Your group has 6 people. Here is/are the suggested team sport(s):

Basketball needs 5 players.

Hockey needs 6 players.

Volleyball needs 6 players.

  • If your group is less than 5 people, see the example below:

Your group has less than 5 people. There is no suggested team sport.

Solutions

Expert Solution

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner in=new Scanner(System.in);

int member[]=new int[]{9,5,11,6,6,7};

String sport[]=new String[]{"Baseball","Basketball","Football","Hockey","Volleyball","Waterpool"};

for(int i=0;i<6;i++)

{

System.out.println(sport[i]+" "+member[i]+" players"); }

System.out.println("\n\n");

int count;

int flag=0;

System.out.print("Enter total number of people in your group:");

count=in.nextInt();

if(count>=5)

{

System.out.println("Your group has "+ count+" players. Here is/are the suggested team sport(s)");

for(int i=0;i<6;i++)

{

if(member[i]<=count)

{

System.out.println(sport[i]+" needs "+ member[i]+" players");

flag=1; } }}

else

System.out.println("Your group has less than 4 players. There is no suggested team sport.");

}

}

please upvote... I need it.. Thanks


Related Solutions

IN JAVA PROGRAMMING Write a complete Java program to do the following: a) Prompt the user...
IN JAVA PROGRAMMING Write a complete Java program to do the following: a) Prompt the user to enter the name of the month he/she was born in (example: September). b) Prompt the user to enter his/her weight in pounds (example: 145.75). c) Prompt the user to enter his/her height in feet (example: 6.5). d) Display (print) a line of message on the screen that reads as follows: You were born in the month of September and weigh 145.75 lbs. and...
DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps: 1....
DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps: 1. Write an abstract Java class called Shape which has only one abstract method named getArea(); 2. Write a Java class called Rectangle which extends Shape and has two data membersnamed width and height.The Rectangle should have all get/set methods, the toString method, and implement the abstract method getArea()it gets from class Shape. 3. Write the driver code tat tests the classes and methods you...
URGENT!!! DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps:...
URGENT!!! DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps: 1. Write an abstract Java class called Shape which has only one abstract method named getArea(); 2. Write a Java class called Rectangle which extends Shape and has two data membersnamed width and height.The Rectangle should have all get/set methods, the toString method, and implement the abstract method getArea()it gets from class Shape. 3. Write the driver code tat tests the classes and methods...
DO THIS IN JAVA Write a complete Java program. the program has two threads. One thread...
DO THIS IN JAVA Write a complete Java program. the program has two threads. One thread prints all capital letters 'A' to'Z'. The other thread prints all odd numbers from 1 to 21.
URGENT!! DO THIS CODE IN JAVA Write a complete Java FX program that displays a text...
URGENT!! DO THIS CODE IN JAVA Write a complete Java FX program that displays a text label and a button.When the program begins, the label displays a 0. Then each time the button is clicked, the number increases its value by 1; that is each time the user clicks the button the label displays 1,2,3,4............and so on.
Need in JAVA. You are to use Binary Trees to do this Program. Write a complete...
Need in JAVA. You are to use Binary Trees to do this Program. Write a complete program, which will process several sets of numbers: For each set of numbers you should: 1. Create a binary tree. 2. Print the tree using “inorder”, “preorder”, and “postorder”. 3. Call a method Count which counts the number of nodes in the tree. 4. Call a method Children which prints the number of children each node has. 5. Inset and delete several nodes according...
Write a complete Java program, including comments in each method and in the main program, to...
Write a complete Java program, including comments in each method and in the main program, to do the following: Outline: The main program will read in a group of three integer values which represent a student's SAT scores. The main program will call a method to determine if these three scores are all valid--valid means in the range from 200 to 800, including both end points, and is a multiple of 10 (ends in a 0). If the scores are...
Write a complete Java program, including comments in each method and in the main program, to...
Write a complete Java program, including comments in each method and in the main program, to do the following: Outline: The main program will read in a group of three int||eger values which represent a student's SAT scores. The main program will call a method to determine if these three scores are all valid--valid means in the range from 200 to 800, including both end points, and is a multiple of 10 (ends in a 0). If the scores are...
Write a complete Java program to print out the name bob
Write a complete Java program to print out the name bob
Java Complete Example.java to fulfill the following problem statement: Write a program to accept a list...
Java Complete Example.java to fulfill the following problem statement: Write a program to accept a list of numbers, one per line. Input is provided from a file if one is provided as the first command line argument. If a file is not provided, input should be read from the terminal. The numbers can either be whole numbers or floating point numbers. The program should continue to accept input until a number equal to 00 is input. Of course, if the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT