Question

In: Computer Science

a.Three strikes bowling lanes hosts an annual tournament for 12 teams. Design a program that accepts...

a.Three strikes bowling lanes hosts an annual tournament for 12 teams. Design a program that accepts each teams name and total score for the tourtament and stores them in parallel arrays. display the names of the top three teams
b. modify the bowling tourtament program so that, instead of the teams total score the program accepts the score of each of the four team members. Display the names of the five top scorers in the tourtament as well as their team names.
just need psuedocode help. not a specific language. thanks

Solutions

Expert Solution

Note: As it was not language-specific. So I have used java for this question.

A)

CODE

import java.util.*;
import java.io.*;

class MyObject {          
       public String teamName;
       public Integer totalScore;
      
      
       public MyObject(String teamName, Integer totalScore){
           this.teamName = teamName;
           this.totalScore = totalScore;
       }
      
   }   

public class Tournament {
  
       public static void main(String[] args) {
          
  
       Scanner sc = new Scanner(System.in);
          
          
       //To create an Array:
       MyObject[] MyObjects = new MyObject[12]; //array of size 12
      
      
       for(int i=0;i<12;i++) {
           System.out.println("Enter team name ");
           String str = sc.next();   
   System.out.println("Enter team total score ");
           int val = sc.nextInt();
           MyObjects[i] = new MyObject(str, val); // Random string and integer in the constructor.
          
       }
      
       // for the display of teams and total score
       /*
       for(int i=0;i<12;i++) {
           System.out.println(MyObjects[i].teamName);
           System.out.println(MyObjects[i].totalScore);
          
       }
       */
      
       int first, second, third;
third = first = second = 0;
      
       for(int i=0;i<12;i++) {
          
           if (MyObjects[i].totalScore > MyObjects[first].totalScore) {
third = second;
second = first;
first = i;
}
  
else if (MyObjects[i].totalScore > MyObjects[second].totalScore) {
third = second;
second = i;
}
  
else if (MyObjects[i].totalScore > MyObjects[third].totalScore)
third = i;
          
       }
       System.out.println("Top three teams are " + MyObjects[first].teamName + " " + MyObjects[second].teamName + " " + MyObjects[third].teamName);
   }  

}

NOTE - I have shown 5 teams for output for a clear and better understanding.

Snapshot -

Output

B)

CODE

import java.util.*;
import java.io.*;

class MyObject {          
       public String teamName;
       public String player1Name;
       public String player2Name;
       public String player3Name;
       public String player4Name;
       public Integer player1;
       public Integer player2;
       public Integer player3;
       public Integer player4;
      
      
       public MyObject(String teamName,String player1Name, Integer player1,String player2Name,
               Integer player2,String player3Name,Integer player3,String player4Name,
               Integer player4){
           this.teamName = teamName;
           this.player1 = player1;
           this.player2 = player2;
           this.player3 = player3;
           this.player4 = player4;
           this.player1Name = player1Name;
           this.player2Name = player2Name;
           this.player3Name = player3Name;
           this.player4Name = player4Name;
       }
      
   }   

public class Tournament {
  
       public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
          
          
       //To create an Array:
       MyObject[] MyObjects = new MyObject[12]; //array of size 12
      
      
       for(int i=0;i<12;i++) {
           System.out.println("Enter team name ");
           String str = sc.next();
           System.out.println("Enter first player name ");
           String pl1 = sc.next();
   System.out.println("Enter first player score ");
           int vpl1 = sc.nextInt();
           System.out.println("Enter second player name ");
           String pl2 = sc.next();
   System.out.println("Enter second player score ");
           int vpl2 = sc.nextInt();
           System.out.println("Enter third player name ");
           String pl3 = sc.next();
   System.out.println("Enter third player score ");
           int vpl3 = sc.nextInt();
           System.out.println("Enter fourth player name ");
           String pl4 = sc.next();
   System.out.println("Enter fourth player score ");
           int vpl4 = sc.nextInt();
          
          
           MyObjects[i] = new MyObject(str, pl1, vpl1, pl2, vpl2, pl3, vpl3, pl4, vpl4);
          
       }
      
       // for display of teams and total score
      
       for(int i=0;i<12;i++) {
           System.out.println(MyObjects[i].teamName);
           System.out.println(MyObjects[i].player1Name);
           System.out.println(MyObjects[i].player1);
           System.out.println(MyObjects[i].player2Name);
           System.out.println(MyObjects[i].player2);
           System.out.println(MyObjects[i].player3Name);
           System.out.println(MyObjects[i].player3);
           System.out.println(MyObjects[i].player4Name);
           System.out.println(MyObjects[i].player4);
          
          
       }
      
       int l=0;
       int m=0;
       int[] arr = new int[48]; // change to 48 for 12 teams
       String[] str1 = new String[48];
               while(l<48) {
                   if(m<12) {
                   arr[l] = MyObjects[m].player1;
                   arr[l+1] = MyObjects[m].player2;
                   arr[l+2] = MyObjects[m].player3;
                   arr[l+3] = MyObjects[m].player4;
                   str1[l] = MyObjects[m].player1Name;
                   str1[l+1] = MyObjects[m].player2Name;
                   str1[l+2] = MyObjects[m].player3Name;
                   str1[l+3] = MyObjects[m].player4Name;
                   l = l+4;
                   m++;
                   }
               }
      
       for(int i=0;i<48;i++) {
           System.out.println(arr[i] + str1[i] );
          
       }
      
       int i;
       int idx[] = new int[5];
   int max = 0, index;
   for (int j = 0; j < 5; j++) {
   max = arr[0];
   index = 0;
   for (i = 1; i < arr.length; i++) {
   if (max < arr[i]) {
   max = arr[i];
   index = i;
  
   }
   }
   idx[j] = index;
   arr[index] = Integer.MIN_VALUE;

   }
  
   System.out.println("Five top scorers are ");
  
  
   for(int k=0;k<5;k++) {
              
       if(idx[k] >= 0 && idx[k] <4) {
           System.out.println("Name:" + str1[idx[k]] + " Team:" + MyObjects[0].teamName);
       }
       else if(idx[k] >= 4 && idx[k] <8) {
           System.out.println("Name:" + str1[idx[k]] + " Team:" + MyObjects[1].teamName);
       }
       else if(idx[k] >= 8 && idx[k] <12) {
           System.out.println("Name:" + str1[idx[k]] + " Team:" + MyObjects[2].teamName);
       }
       else if(idx[k] >= 12 && idx[k] <16) {
           System.out.println("Name:" + str1[idx[k]] + " Team:" + MyObjects[3].teamName);
       }
       else if(idx[k] >= 16 && idx[k] <20) {
           System.out.println("Name:" + str1[idx[k]] + " Team:" + MyObjects[4].teamName);
       }
       else if(idx[k] >= 20 && idx[k] <24) {
           System.out.println("Name:" + str1[idx[k]] + " Team:" + MyObjects[5].teamName);
       }
       else if(idx[k] >= 24 && idx[k] <28) {
           System.out.println("Name:" + str1[idx[k]] + " Team:" + MyObjects[6].teamName);
       }
       else if(idx[k] >= 28 && idx[k] <32) {
           System.out.println("Name:" + str1[idx[k]] + " Team:" + MyObjects[7].teamName);
       }
       else if(idx[k] >= 32 && idx[k] <36) {
           System.out.println("Name:" + str1[idx[k]] + " Team:" + MyObjects[8].teamName);
       }
       else if(idx[k] >= 36 && idx[k] <40) {
           System.out.println("Name:" + str1[idx[k]] + " Team:" + MyObjects[9].teamName);
       }
       else if(idx[k] >= 40 && idx[k] <44) {
           System.out.println("Name:" + str1[idx[k]] + " Team:" + MyObjects[10].teamName);
       }
       else if(idx[k] >= 44 && idx[k] <48) {
           System.out.println("Name:" + str1[idx[k]] + " Team:" + MyObjects[11].teamName);
       }
      
   }
  
   }  

}

I have tried to answer the question as briefly and simply as possible if you find any problem in the solution provided ask in comment and provide feedback.



Related Solutions

Design a program using a flowchart or pseudocode that accepts a person’s loyalty card number and...
Design a program using a flowchart or pseudocode that accepts a person’s loyalty card number and amount spent in the store last month. Display the data only if the customer is a high spender – a person who spent more than $1000 in the store. A program that accepts customer info continuously until a sentinel value is entered and displays a list of high spenders.
Design, code, and test a program that accepts positive integers until the value 204 is entered....
Design, code, and test a program that accepts positive integers until the value 204 is entered. After input terminates, the program should report the total number of even integers (excluding the special number 204) , the average value of the even integers, the total number of odd integers, and the average value of the odd integers. The program should also report "Evens won!", "Odds won!", or "Evens and odds tied!" based on which total was greater. Test your program thoroughly...
Design a modular program that accepts as input 20 numbers between 0 and 100 (including 0...
Design a modular program that accepts as input 20 numbers between 0 and 100 (including 0 and 100). The program should store the numbers in an array and then display the following information: The lowest number in the array The highest number in the array The total of the numbers in the array The average of the numbers in the array Your program should consist of the following: Module main. Accepts input of numbers and assigns them to an array....
Training Program: Design a full 12-week periodized training program for the client described in the Client...
Training Program: Design a full 12-week periodized training program for the client described in the Client Profile. Be very specific as you design the training program. This is an opportunity for you to demonstrate your full comprehension of the information and concepts discussed throughout the course. List the types of exercise, duration, sets, reps, rest intervals, and so on. Include the following in your case study submission: A description of your professional responsibilities as discussed in the stages of the...
Design a program that lets the user enter the total rainfall for each of 12 months...
Design a program that lets the user enter the total rainfall for each of 12 months into an array. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts. Requirements You must use the given function prototypes. You can add more functions if you like. def get_total_rainfall(months, months_len): def get_average_monthly_rainfall(months, months_len): def get_month_with_highest_rainfall(months, months_len): def get_month_with_lowest_rainfall(months, months_len): Design Considerations Use a global parallel array of...
Design a program that lets the user enter the total rainfall for each of 12 months...
Design a program that lets the user enter the total rainfall for each of 12 months into a list. The program should calculate and display the total rainfall for the year, the average monthly rainfall, the months with the highest and lowest amounts. This is my Pthon 3.8.5 code so far: #Determine Rainfall Program for a 12 month Period #It should calculate and output the "total yearly rainfall, avg monthly rainfall, the months with highest and lowest amounts #list of...
design a program that lets the user enter the total rainfall for each of 12 months...
design a program that lets the user enter the total rainfall for each of 12 months into an array. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts.   ---->>> Enhance the program so it sorts the array in ascending order and displays the values it contains. You can choose which sorting algorithm to use (bubble sort, selection sort, or insertion sort). Depending on your...
Design a program that lets the user enter the total rainfall for each of 12 months...
Design a program that lets the user enter the total rainfall for each of 12 months into an array. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts. Design a program to solve Chapter 8 Programming Exercise 3 (Rainfall Statistics) in your textbook. Create parallel arrays for the month names and rainfall amounts for each month. Use month names (i.e. January, February, March, etc.)...
Design a 12 Week Exercise and Nutritional Guidance Program for the following case: \Female, 49 years...
Design a 12 Week Exercise and Nutritional Guidance Program for the following case: \Female, 49 years old VO2 MAX= 31 ml/kg/min BP: 130/85 Fasting Glucose: 99 mg/dl Right Sided low back pain LDL cholesterol: 110 mg/dl C-section Resting Heart Rate: 80 bpm Please provide rationale for your program. Word requirement: 200-250 words What is the disease risk classification for this client? What considerations will make when designing her program? Target exercise intensity What assessments will you use to gather baseline...
Design a 12 Week Exercise and Nutritional Guidance Program for the following case: Female, 49 years...
Design a 12 Week Exercise and Nutritional Guidance Program for the following case: Female, 49 years old VO2 MAX= 31 ml/kg/min BP: 130/85 Fasting Glucose: 99 mg/dl Right Sided low back pain LDL cholesterol: 110 mg/dl C-section Resting Heart Rate: 80 bpm Please provide rationale for your program. Word requirement: 200-250 words What is the disease risk classification for this client? What considerations will make when designing her program? Target exercise intensity What assessments will you use to gather baseline...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT