Write a class named TestScores. The class constructor should accept an array of test scores as its argument. The class should have a method that returns the average of the test scores.

java

LANGUAGE: JAVA CHALLENGE: Write a class named TestScores. The class constructor should accept an array of test scores as its argument. The class should have a method that returns the average of the test scores. If any test score in the array is negative or greater than 100, the class should throw an IllegalArgumentException. Demonstrate the…

Read More

Write the definition of a class named SQRTException whose objects are created by specifying the original negative value that caused the problem in the first place: new SQRTException(originalArgument).

java

LANGUAGE: JAVA CHALLENGE: The argument to a square root method (sqrt) in general should not be negative. Write the definition of a class named SQRTException whose objects are created by specifying the original negative value that caused the problem in the first place: new SQRTException(originalArgument). The associated message for this Exception should be “Bad argument to…

Read More

Write some code that invokes the process method provided by the object associated with processor and arrange matters so that if any exception is thrown success to be set to false but otherwise it is set to true

java

LANGUAGE: Java CHALLENGE: Assume that success is a variable of type boolean that has been declared. Assume that processor refers to an object that provides a void method named process that takes no arguments. As it happens, the process method may throw one of several exceptions. Write some code that invokes the process method provided…

Read More

Define a class, Window, that implements the GUIComponent interface, and has the following members

java

LANGUAGE: Java CHALLENGE: Assume the existence of an interface, GUIComponent with the following methods: – open and close: no parameters, returns boolean – move and resize: accepts two integer parameters and returns void Define a class, Window, that implements the GUIComponent interface, and has the following members: – width, height, xPos, and yPos integer instance…

Read More