1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Mamont248 [21]
4 years ago
10

Write an exception class named InvalidTestScore. Modify the TestScores class you wrote in Part I so that it throws an InvalidTes

tScore exception if any of the test scores in the array are invalid. Test your exception in a program (in a subclass located in the same file). Your program should prompt the user to enter the number of test scores, and then ask for each test score individually. Then, it should print the average of test scores. If the average method throws an InvalidTestScore exception, the main method should catch it and print "Invalid test score."
Computers and Technology
1 answer:
Elan Coil [88]4 years ago
8 0

Answer:

See Explaination

Explanation:

package testscores;

import java.util.ArrayList;

import java.util.List;

public class TestScores {

public List<Integer> scorearray=new ArrayList<>();

public TestScores(List<Integer> scores) throws InvalidTestScore{

this.scorearray=scores;

for(int i=0;i<scorearray.size();i++){

if(scorearray.get(i)>100 || scorearray.get(i)<0){

throw new InvalidTestScore(this.scorearray.get(i));

}

}

}

public double average(){

int tot=0;

for(int i=0;i<this.scorearray.size();i++){

tot=tot+this.scorearray.get(i);

}

return tot*(1.0)/(this.scorearray.size());

}

class InvalidTestScore extends Exception

{

private double amount;

public InvalidTestScore(int Score)

{

System.out.println("Invalid Score "+Score);

}

}

}

You might be interested in
Help, with gaming unlocked
Leto [7]

Answer:

C. empathic understanding

8 0
4 years ago
Which of the following goals states a quantifiable outcome of a project?
Ugo [173]

Answer:

An increase in revenue

Explanation:

We cannot predict how much revenue growth we are going to generate, and at what time. And hence, 2 and 3 are not an option here. Also, a TV science show has nothing to do with the quantifiable outcome of a project. And what is true is certainly that there is going to be an increase in revenue, which can certainly predict if we feel work was good and ended with good results. And hence the above option is the correct option for this question.

6 0
4 years ago
Explain synchronized plug firing.
eimsori [14]
HEY THERE!!

In a camera, flash synchronization is defined as synchronizing the firing of a photographic flash with the opening of the shutter admitting light to photographic film or electronic image sensor. It is often shortened to flash sync  or flash synch.


HOPE IT HELPS
6 0
3 years ago
This standard library function returns a random floating-point number in the range of 0.0 up to 1.0 (but not including 1.0).
natulia [17]

Answer:

The answer would be A: Random

Explanation:

The random() function returns a generated random number (a pseudorandom number)

5 0
3 years ago
what is the least expensive way to connect five computers using a wired network to a router that has only four network ports?
ExtremeBDS [4]

Answer: Get wifi.

Explanation: Get wifi.

5 0
2 years ago
Other questions:
  • To add another worksheet to an Excel file, click on the _____
    15·1 answer
  • Represent the logic of a program that allows the user to enter a value for one edge of a cube. The program calculates the surfac
    10·1 answer
  • Given the following HTML form snippet of markup, which of the following user inputs would meet the regular expression rule writt
    7·1 answer
  • Which one of the following UNIX utilities is purpose-built to quickly return the location (filepath) of files by querying a data
    15·1 answer
  • What does the action tool allow you to do in Microsoft power point?
    9·1 answer
  • The paint 3D program is used for drawing picture true or false​
    10·2 answers
  • Uuhdcnkhbbbbhbnbbbbnnnnnnnnnfddjkjfs
    14·1 answer
  • What is the purpose of exploring data?
    6·2 answers
  • Why do we need on output device?​
    11·2 answers
  • Assignment 2: room area <br>programming python in Project Stem​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!