======================
JAVA PROGRAM
======================
///////////////////////GroupScore.java////////////////////////
import java.io.File;
import java.util.Scanner;
/**
* File: GroupScore.java
*/
public class GroupScore {
public static void main(String[] args){
//initialize the counter
variables
int totalGroupsProcessed = 0;
int numOfValidGroups = 0;
int numOfInvalidGroups = 0;
//create instance of GroupScore
class
GroupScore gs = new
GroupScore();
int score1,score2,score3;
File file = new File(""); //dumym
file instance created
Scanner sc = new
Scanner(System.in);//instantiate scanner
//start infinite do-while
loop
do{
//read
score1,score2 and score3 from user
System.out.println("Score1 :");
score1 =
sc.nextInt();
System.out.println("Score2 :");
score2 =
sc.nextInt();
System.out.println("Score3 :");
score3 =
sc.nextInt();
totalGroupsProcessed++;//increase groups processed count
//checks if
group is valid
boolean
isValidGroup = gs.validGroup(score1, score2, score3, file);
if(!isValidGroup){//if invalid
numOfInvalidGroups++;//increase invalid
counter
System.out.print("\n\n\n");
continue;//go for next iteration
}
//the flow has
reached here means it is a valid group
numOfValidGroups++;//increase valid counter
//call
oneGameScore for score1,score2 and score3 sequentially
gs.oneGameScore(score1, file);
gs.oneGameScore(score2, file);
gs.oneGameScore(score3, file);
//calculate and
print avg score
double avg =
gs.avg3Scores(score1, score2, score3);
System.out.println("Average = "+ avg);
//pass avg to
one game score
gs.oneGameScore(avg,file);
//0 to stop the
loop
System.out.println("1 to proceed and 0 to stop:");
int check =
sc.nextInt();
if(check==0){
break; //if 0 has been input stop the loop
}
System.out.print("\n\n\n");
}while(true);
sc.close();
//print the counters
System.out.println("Total Number of
groups processed: "+totalGroupsProcessed);
System.out.println("The number of
valid groups: "+numOfValidGroups);
System.out.println("The number of
invalid groups: "+numOfInvalidGroups);
}
/**
* checks if the 3 scores make a valid group or
not
* @param score1
* @param score2
* @param score3
* @param file
* @return
*/
private boolean validGroup(int score1,int score2,int
score3, File file){
boolean isValidGroup = false;
if(score1 >=0 && score1
<=300){
if(score2 >=0
&& score2 <=300){
if(score3 >=0 && score3
<=300){
isValidGroup = true;
}else{
System.out.println("Score3="+score3+" is invalid.");
if(score3<0){
System.out.println("It is less than 0.");
}else{
System.out.println("It is greater than 300.");
}
}
}else{
System.out.println("Score2="+score2+" is
invalid.");
if(score2<0){
System.out.println("It is
less than 0.");
}else{
System.out.println("It is
greater than 300.");
}
}
}else{
System.out.println("Score1="+score1+" is invalid.");
if(score1<0){
System.out.println("It is less than 0");
}else{
System.out.println("It is greater than
300");
}
}
return isValidGroup;
}
/**
* determine rating from score
* @param score
* @param file
*/
private void oneGameScore(double score, File
file){
String rating = null;
if(score >=250 && score
<=300){
rating =
"professional game";
}else if(score >=200 &&
score<=249){
rating =
"excellent game";
}else if(score >=140 &&
score<=199){
rating = "very
good game";
}else if(score >=100 &&
score<=139){
rating = "good
game";
}else if(score >=50 &&
score<=99){
rating = "poor
game";
}else if(score < 50){
rating =
"horrible game";
}
System.out.println("Original score
="+score);
System.out.println("Bowler's
rating: "+rating);
}
/**
* calculates average
* @param score1
* @param score2
* @param score3
* @return
*/
private double avg3Scores(int score1,int score2,int
score3){
double avg =
(double)(score1+score2+score3)/3;
return avg;
}
}
=============================
OUTPUT
=============================
Score1 :
100
Score2 :
156
Score3 :
201
Original score =100.0
Bowler's rating: good game
Original score =156.0
Bowler's rating: very good game
Original score =201.0
Bowler's rating: excellent game
Average = 152.33333333333334
Original score =152.33333333333334
Bowler's rating: very good game
1 to proceed and 0 to stop:
1
Score1 :
40
Score2 :
56
Score3 :
97
Original score =40.0
Bowler's rating: horrible game
Original score =56.0
Bowler's rating: poor game
Original score =97.0
Bowler's rating: poor game
Average = 64.33333333333333
Original score =64.33333333333333
Bowler's rating: poor game
1 to proceed and 0 to stop:
1
Score1 :
-5
Score2 :
100
Score3 :
45
Score1=-5 is invalid.
It is less than 0
Score1 :
45
Score2 :
789
Score3 :
103
Score2=789 is invalid.
It is greater than 300.
Score1 :
100
Score2 :
200
Score3 :
300
Original score =100.0
Bowler's rating: good game
Original score =200.0
Bowler's rating: excellent game
Original score =300.0
Bowler's rating: professional game
Average = 200.0
Original score =200.0
Bowler's rating: excellent game
1 to proceed and 0 to stop:
0
Total Number of groups processed: 5
The number of valid groups: 3
The number of invalid groups: 2
I've been trying to do this and cant figure it out. Please help me with this...
How to write a code for this?When the program starts the bowler is prompted for a score for ‘Game 1’Accept the bowling score from the user; valid bowling scores are whole numbers between 0 and 300.Once a valid numeric score is entered then perform range validation to ensure it is within the required entry range. If the bowler enters a value outside of the acceptable range, or for any entries that aren’t whole numbers, the program should display an appropriate...
ANY HELP PLEASE. PLEASE READ THE WHOLE INSTRUCTION THANK YOU Write a program GS.java that will be responsible for reading in the names and grades for a group of students, then reporting some statistics about those grades. The statistics to be gathered are the number of scores entered, the highest score and the name(s) of the student(s) who earned that score, the lowest score and the name(s) of the student(s) who earned that score, and the average score for the...
Implement a Java program using simple console input & output and logical control structures such that the program prompts the user to enter 5 integer scores between 0 to 100 as inputs and does the following tasks For each input score, the program determines whether the corresponding score maps to a pass or a fail. If the input score is greater than or equal to 60, then it should print “Pass”, otherwise, it should print “Fail”. After the 5 integer...
Write a complete Java program, including comments in both the main program and in each method, which will do the following: 0. The main program starts by calling a method named introduction which prints out a description of what the program will do. This method is called just once. This method is not sent any parameters, and it does not return a value. The method should print your name. Then it prints several lines of output explaining what the...
This is used as C++ How do I even figure this out at all? Please help me solve this tough question Question 30 10 pts (SHORT ANSWER) Write three separate if blocks to check the following THREE conditions (number your answers): 1. If the number variable testScore is outside the range of 0 through 100 (excluding both those scores), print the message: "INVALID: OUTSIDE RANGE 0-100" 2. If the number variable bonusPoints is inside the range 1 through 10 (including...
Write a complete JAVA program to do the following program. The main program calls a method to read in (from an input file) a set of people's three-digit ID numbers and their donations to a charity (hint: use parallel arrays)Then the main program calls a method to sort the ID numbers into numerical order, being sure to carry along the corresponding donations. The main program then calls a method to print the sorted 1ists in tabular form, giving both ID...
I want to know how to do this assignment!!! Help me please~ The first part of your program should do the following: • Ask the user type of test they took. o (ACT or SAT) • If they said ACT then ask them their score o If their ACT score was between 0 and 7 say "Needs Work" o If their ACT score was between 10 and 20 say "Acceptable" o If they ACT score was above 20 say "Above...
CAN SOMEONE PLEASE HELP ME WRITE THIS CODE IN C++, PLEASE HAVE COMMENTS IN THE CODE IF POSSIBLE!! General Description: Write a program that allows the user to enter data on their friends list. The list holds a maximum of 10 friends, but may have fewer. Each friend has a name, phone number, and email address. The program first asks the user to enter the number of friends (1-10). You are not required to validate the entry, but you may...
in java plz amaining Time: 1 hour, 49 minutes, 15 seconds. Jestion Completion Status: Write a program that asks the user for an input file name, open, read ar number of students is not known. For each student there is a name and and display a letter grade for each student and the average test score fc • openFile: This method open and test the file, if file is not found and exit. Otherwise, return the opened file to the...
please use java do what u can 1. Modify the Student class presented to you as follows. Each student object should also contain the scores for three tests. Provide a constructor that sets all instance values based on parameter values. Overload the constructor such that each test score is assumed to be initially zero. Provide a method called set Test Score that accepts two parameters: the test number (1 through 3) and the score. Also provide a method called get...