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
Maya is preparing a presentation for her science class on how solar panels produce energy. Why would a
astra-53 [7]
A.) it the best way to show how something functions
5 0
3 years ago
Read 2 more answers
What is the advantage of learning through story compared to learning through personal experience?
Inessa [10]

Answer:

Personal Experience

Explanation:

If a story is based on a personal experience then yes, the two doesn't matter. <em>However</em>, usually learning through personal experience is better because you learn firsthand while stories are written from a different perspective.

6 0
3 years ago
Read 2 more answers
What is the output for the following code?<br><br> print (5*4+5)
Damm [24]

Answer:

It will just print 5*4+5 .

But you still need to add " ".

8 0
3 years ago
Write a C++ program to exchange values of two variables using function exchange().
Shkiper50 [21]

Answer:

#include<iostream>

using namespace std;

//create the exchange function

void exchange(int a, int b){

   int temp;  //initialize temporary

   //swap the variables value

   temp=a;

   a=b;

   b=temp;

   //print the output after exchange

   cout<<"a is: "<<a<<endl;

   cout<<"b is: "<<b<<endl;

}

//main function program start from here

int main(){

  //initialization

  int a=3, b=6;

  exchange(a,b);  //calling the function

  return 0;

}

Explanation:

Create the function exchange with two integer parameter which takes the value from the calling function.

and then declare the third variable temp with is used for swapping the value between two variables.

first store the value of 'a' in the temp and then assign the 'b' value to 'a' and then, assign the temp value to b.

for example;

a=2, b=9

temp=2;

a=9;

b=2;

So, the values are swap.  

and then print the swap values.

Create the main function and define the input a and b with values.

Then, calling the exchange function with two arguments.

6 0
3 years ago
As you are working on the Datacenter Edition server, you install a card to connect a set of RAID drives. After the card and driv
sweet [91]

Answer:

by fixing it with card

Explanation:

you have taken out the card I thing

4 0
3 years ago
Other questions:
  • Collins and quillian explained the results of priming experiments by introducing the concept of _____ into their network model.
    12·1 answer
  • As the design phase of an SDLC begins, programming languages, development tools, and application software needed for the new inf
    13·1 answer
  • What are indexes in a database?
    14·1 answer
  • What does this mean?
    11·2 answers
  • Sandra wants to have her new technology up and running as soon as possible. She is looking for a tool that she can
    8·1 answer
  • arlos, an algebra teacher, is creating a series of PowerPoint presentations to use during class lectures. After writing, formatt
    12·2 answers
  • On which of the following pointing devices can you control the pointer by sliding your fingertip?
    11·1 answer
  • Describe how operating system use the following security tools: firewall, automatic updating, antivirus software, spyware and ma
    11·1 answer
  • Add and multiply
    10·1 answer
  • Why big data influnce the rise of AI<br><br>​
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!