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
Distinguish the functional requirements an engineer would have to specify for a taxi dispatch system.
AveGali [126]
The requirements are mainly written in a feature style notation, using some state charts, context diagrams and other techniques to describe certain parts of the system. See, for example, Software Requirements - Styles and Techniques [Lauesen00].
The functional requirements are divided into four sections. The three modules in figure 1 are developed by separate groups, each responsible for unit testing. All requirements for the taxi, central and communication link component are written in a feature style notation. In addition, a special part of the taxi component is the positioning system. This is dealt with separately since there are special requirements present on this component. The functional requirements consist of four sections: Taxi (3.1), Central (3.2), Communication link (3.3) and Positioning system (3.4). 
6 0
3 years ago
When the increment or decrement operator is placed before the operand (or to the operand's left), the operator is being used in
Salsk061 [2.6K]

When the increment or decrement operator is placed before the operand (or to the operand's left), the operator is being used in prefix mode. Postfix mode on the other hand is when the increment or decrement operator is placed after the operand (or to the oper and's right) .


8 0
3 years ago
The process of encoding messages or information in such a way that only authorized parties can read it is called ____________.
lukranit [14]

Answer:

Encryption

Explanation:

Encryption is a term in the field of computer security (Cryptology) this is a process of encoding information in a way that hackers and eavesdroppers cannot read. The process of encryption involves a plain text (message) been converted into a scrambled text (cipher text) with an encryption algorithm (key) in this way, if the message is intercepted by a hacker he/she is unable to read the contents. Only the authorized party with a decryption key will be able to decrypt back to a plain text and read the contents of the message

3 0
2 years ago
Does anyone know how to write this right? This is for a coding class and I’m super confused on it.
vovangra [49]

Answer:

This is using c++ syntax, you might need to make slight adjustment for other languages.

First activity:

string firstSnack = "chips";

string secondSnack = "pizza";

string thirdSnack = "apples";

string bestSnack =  firstSnack;

bestSnack = secondSnack;

Second activity:

double apple = 0.5;

double banana = 0.75;

double orange = 1.43;

double total = apple + banana + orange;

Explanation:

When first declaring a variable, you want to specify the type (such as int, double, string, bool, etc.) and then the name. You can set the variable value in the declaration, or you can set it to a value later in the program by not having the equals sign and whatever comes next.

4 0
2 years ago
A common preprocessing step in many natural language processing tasks is text normalization, wherein words are converted to lowe
Arturiano [62]

Answer:

def normalize(text):

   text = text.lower()

   text = text.split()

   return text

Explanation:

The functiinfunction is provided with an input text when called upon, then it changes every character in the text into lower case and split each word with a space.

4 0
3 years ago
Other questions:
  • Damion recently did an update to his computer and added a new video card. After the update, Damion decided that he would like to
    13·1 answer
  • What is the very first thing a user usually must do to gain access to a secure computer?
    7·1 answer
  • Which of the following is NOT a fixed expense?
    6·1 answer
  • A computer with a frequency 2 GHZ and its average cycle per instruction is 2. what is the MIPS of the computer?
    6·1 answer
  • Which career path includes the work duties of hiring and managing farm laborers?
    6·2 answers
  • Find the Nearest Repeated Entries in an Array People do not like reading text in which a word is used multiple times in a short
    15·1 answer
  • Yall like portal 1 or 2
    8·1 answer
  • What is the scope of numC?
    8·2 answers
  • What type of access controls allow the owner of a file to grant other users access to it using an access control list
    5·1 answer
  • Hiiiiiiiiihwdawdfgthnythgrfergthyjuhgfd
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!