You have been asked to create a program for the Bergen Bowling team. They would
ID: 3572263 • Letter: Y
Question
You have been asked to create a program for the Bergen Bowling team. They would like a program that displays statistics about their performance after their recent match. The information they have provided to you is as follows:
The program should display a variety of statistics including:
1. The average for each bowler in descending order.
2 The average for each game in ascending order.
3 The name of the bowler who bowled the highest game along with the score.
4 The name of the bowler who bowled the lowest game along with the score Assessment.
Your program will be assessed on the following criteria
Full Functionality – program executes without error 10 Points
Deployment of an array based solution 20 Points
Proper documentation through comments 10 Points
Meets all client specifications 10 Points
*Also in a seperate program include Advance Inheritance, Handling, File input and output, Swing components and GUI.
Bowler Game1 Game 2 Game 3 John Smith 186 210 140 Peter James 204 200 220 Mary Adams 283 189 220 Pamela Ennis 198 223 135 Mike Smith 234 293 135Explanation / Answer
************************Bowler.java**********************
package bowler;
public class Bowler {
public static void main(String[] args) {
// TODO code application logic here
String bowlerName[]=new String[5];
float[] avgBowler = new float[5];
float[] avgGame = new float[3];
String[] gameArr={"Game1","Game2","Game3"};
int arr[]={186,210,140,204,200,220,283,189,220,198,223,135,234,293,135};
bowlerName[0]="John Smith";
bowlerName[1]="Peter James";
bowlerName[2]="Mary Adams";
bowlerName[3]="Pamela Enis";
bowlerName[4]="Mike Smith";
int j=0;
System.out.println(" Statistics: ");
//calculates average for each bowler in normal order
for(int i=0;i<5;i++){
avgBowler[i]=(arr[j]+arr[j+1]+arr[j+2])/3;
j=j+3;
}
j=0;
//calculates average for each game in normal order
for(int i=0;i<3;i++){
avgGame[i]=arr[j]+arr[j+3]+arr[j+6]+arr[j+9]+arr[j+12]/5;
j=j+1;
}
int n = 5;
float temp = 0;
String name="";
//sorting the average for bowler in descending order
for (int i = 0; i < n; i++)
{
for (int k = i + 1; k < n; k++)
{
if (avgBowler[i] < avgBowler[k])
{
temp = avgBowler[i];
avgBowler[i] = avgBowler[k];
avgBowler[k] = temp;
name=bowlerName[i];
bowlerName[i]=bowlerName[k];
bowlerName[k]=name;
}
}
}
//sorting the game average for bowler in ascending order
n = 3;
temp = 0;
name="";
//sorting the average for game in ascending order
for (int i = 0; i < n; i++)
{
for (int k = i + 1; k < n; k++)
{
if (avgGame[i] > avgGame[k])
{
temp = avgGame[i];
avgGame[i] = avgGame[k];
avgGame[k] = temp;
name=gameArr[i];
gameArr[i]=gameArr[k];
gameArr[k]=name;
}
}
}
System.out.println("The average for each bowler in descending order:");
for(int i=0;i<5;i++){
System.out.println(bowlerName[i]+" "+avgBowler[i]);
}
System.out.println("The average for each game in ascending order:");
for(int i=0;i<3;i++){
System.out.println(gameArr[i]+" "+avgGame[i]);
}
System.out.println("The name of the bowler who bowled the highest game along with the score:"+bowlerName[0]+" "+avgBowler[0]);
System.out.println("The name of the bowler who bowled the lowest game along with the score Assessment:"+bowlerName[4]+" "+avgBowler[4]);
}
}
*********************OUTPUT*****************************
The average for each bowler in descending order:
Mary Adams 230.0
Mike Smith 220.0
Peter James 208.0
Pamela Enis 185.0
John Smith 178.0
The average for each game in ascending order:
Game3 742.0
Game2 880.0
Game1 917.0
The name of the bowler who bowled the highest game along with the score:Mary Adams 230.0
The name of the bowler who bowled the lowest game along with the score Assessment:John Smith 178.0
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.