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]
3 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]3 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
How do I give Brainliest? Will give brainliest when I figure out how
Lina20 [59]
When somebody writes the answer for your question and posts it on your question it will show a “(crown)mark as brainliest” in blue. click it and it’ll turn yellow and mark the person the brainliest for your question
7 0
3 years ago
Read 2 more answers
ISO 400 is twice as sensitive and ISO 100 true or false
beks73 [17]

Answer:

Quite simply, when you double your ISO speed, you are doubling the brightness of the photo. So, a photo at ISO 400 will be twice brighter than ISO 200, which will be twice brighter than ISO 100.

Explanation:

ISO most often starts at the value of ISO 100. This is the lowest, darkest setting, also called the base ISO. The next full stop, ISO 200, is twice as bright, and ISO 400 is twice as bright than that. Thus, there are two stops between ISO 100 and 400, four stops between 100 and 1600, and so on.

4 0
2 years ago
¿Por qué es importante que lo países crezcan a nivel tecnológico?
IrinaK [193]

Answer:

Importancia de la tecnología en el crecimiento económico de los países. ... El desarrollo de estas vías tecnológicas aporta un aspecto positivo como el ahorro del tiempo, la disminución de los esfuerzos de los trabajadores que permite una economía progresiva.

Explanation:

4 0
2 years ago
A. Write a program that asks the user to enter an integer, then prints a list of all positive integers that divide that number e
kobusy [5.1K]

Answer:

Following are the program in python language the name of the program is factors.py

num= int(input("Please enter a positive integer: "))#Read the number by user

print("The factors of ",num,"are:")

for k in range(2,num): #iterating over the loop

   if(num%k==0): #checking the condition

       print(k)#display the factor

Output:

Please enter a positive integer: 12

The factors of 12 are:

2

3

4

6      

Explanation:

Following are the description of the program

  • Read the number by user in the "num" variable
  • Iterating the for loop from k=2 to less then "num".
  • In the for loop checking the factor of "num"  variable by using % operator.
  • Finally display the factor by using print function
4 0
3 years ago
Which of the following is true of the Internet as a medium for branding? a) The Internet is more effective as a media for brandi
alexira [117]

Answer:

The answer to this question is option "d".

Explanation:

Internet branding describes as a brand management system that allows us to use the Internet as a tool for promoting the products. In other words, we can say that advertising the product on the Internet is known as Digital marketing. and other options are not correct that can be defined as:

  • In option a, It does not provide one-directional communication flow.
  • The b, c, and e options are not correct, because the internet is an effective medium for branding and it also provides services for branding.  

3 0
2 years ago
Other questions:
  • Which function should be used to display a value based on a comparison?
    11·1 answer
  • The process of changing a program’s internal structure without changing the way the program works is ______________.
    13·1 answer
  • The most commonly used video formats are the mpeg-____ format, the windows media audio/video format, and the audio visual interl
    12·1 answer
  • A USB zipper drive is a small data storage device that plugs into a computer's USB port.
    14·1 answer
  • The
    6·2 answers
  • Write a program that prints the following 45 pairs of numbers:
    8·1 answer
  • 我对汉语的兴趣 làm đoạn văn theo đề trên​
    14·1 answer
  • Write a pseudocode that receives a positive number from the user, and then,
    14·1 answer
  • How to disable Fortinet?
    12·1 answer
  • Jason Chang is creating photos of his restaurant for a new website. Some of the photos of the staff have red eye, others are bad
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!