Category: Java

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.

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.

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...

This content requires that you purchase additional access. The price is $2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

Purchase this Content ($2.99) Choose a Membership Level

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).

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).

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...

This content requires that you purchase additional access. The price is $2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

Purchase this Content ($2.99) Choose a Membership Level

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

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

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...

This content requires that you purchase additional access. The price is $2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

Purchase this Content ($2.99) Choose a Membership Level

Read More

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

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

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...

This content requires that you purchase additional access. The price is $2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

Purchase this Content ($2.99) Choose a Membership Level

Read More

Come up with a recursive definition and use it to guide you to write a method definition for a double -valued method named harmonic that accepts an int parameters n and recursively calculates and returns the nth harmonic number.

Come up with a recursive definition and use it to guide you to write a method definition for a double -valued method named harmonic that accepts an int parameters n and recursively calculates and returns the nth harmonic number.

LANGUAGE: Java CHALLENGE: The nth harmonic number is defined non-recursively as: 1 +1/2 + 1/3 + 1/4 + … + 1/n. Come up with a recursive definition and use it to guide you to write a method definition for a double -valued method named harmonic that accepts an int parameters n and recursively calculates and...

This content requires that you purchase additional access. The price is $2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

Purchase this Content ($2.99) Choose a Membership Level

Read More

A palindrome is a string that reads the same forwards or backwards; for example dad, mom, deed (i.e., reversing a palindrome produces the same string )

A palindrome is a string that reads the same forwards or backwards; for example dad, mom, deed (i.e., reversing a palindrome produces the same string )

LANGUAGE: Java CHALLENGE: A palindrome is a string that reads the same forwards or backwards; for example dad, mom, deed (i.e., reversing a palindrome produces the same string ). Write a recursive, boolean -valued method, isPalindrome that accepts a string and returns whether the string is a palindrome. A string , s, is a palindrome...

This content requires that you purchase additional access. The price is $2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

Purchase this Content ($2.99) Choose a Membership Level

Read More

Assume the existence of a Window class with the following methods : – widen – accepts no arguments;

Assume  the existence of a Window class  with the following methods : – widen – accepts no arguments;

LANGUAGE: Java CHALLENGE: Assume the existence of a Window class with the following methods : – widen – accepts no arguments; doubles the width of the window – setHeight – accepts an integer argument corresponding to the new height of the Window – getWidth and getHeight – accept no arguments , return the width and...

This content requires that you purchase additional access. The price is $2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

Purchase this Content ($2.99) Choose a Membership Level

Read More

Assume the existence of a Window class with methods getWidth and getHeight, and a subclass TitledWindow, with a constructor accepts a string corresponding to the title of the window.

Assume the existence of a Window class  with methods getWidth and getHeight, and a subclass TitledWindow, with a constructor accepts a string corresponding to the title of the window.

LANGUAGE: Java CHALLENGE: Assume the existence of a Window class with methods getWidth and getHeight, and a subclass TitledWindow, with a constructor accepts a string corresponding to the title of the window. Declare a variable , tWindow, of type TitledWindow variable , and initialize it to a TitledWindow object with a title of “My Title”....

This content requires that you purchase additional access. The price is $2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

Purchase this Content ($2.99) Choose a Membership Level

Read More

You are given two int variables j and k, an int array zipcodeList that has been declared and initialized, and an boolean variable duplicates.

You are given two int variables j and k, an int array zipcodeList that has been declared and initialized, and an boolean variable duplicates.

LANGUAGE: Java CHALLENGE: You are given two int variables j and k, an int array zipcodeList that has been declared and initialized, and an boolean variable duplicates. Write some code that assigns true to duplicates if any two elements in the array have the same value , and that assigns false to duplicates otherwise. Use...

This content requires that you purchase additional access. The price is $2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

Purchase this Content ($2.99) Choose a Membership Level

Read More

Given the integer variables x and y, write a fragment of code that assigns the larger of x and y to another integer variable max.

Given the integer variables x and y, write a fragment of code that assigns the larger of x and y to another integer variable max.

LANGUAGE: Java CHALLENGE: Given the integer variables x and y, write a fragment of code that assigns the larger of x and y to another integer variable max....

This content requires that you purchase additional access. The price is $2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

Purchase this Content ($2.99) Choose a Membership Level

Read More

The method shown below, makeJunk generates compile-time error: “unreported exception java.io.IOException; must be caught or declared to be thrown”.

The method shown below, makeJunk generates compile-time error: “unreported exception java.io.IOException; must be caught or declared to be thrown”.

LANGUAGE: Java CHALLENGE: The method shown below, makeJunk generates compile-time error: “unreported exception java.io.IOException; must be caught or declared to be thrown”. Without changing the behavior (any part of the method body ) and without changing the number of arguments the function takes or its visibility, add the necessary code that will permit this code...

This content requires that you purchase additional access. The price is $2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

Purchase this Content ($2.99) Choose a Membership Level

Read More

Write a static method, getBigWords, that gets a single String parameter and returns an array whose elements are the words in the parameter that contain more than 5 letters. (A word is defined as a contiguous sequence of letters.)

Write a static method, getBigWords, that gets a single String  parameter and returns an array whose elements are the words in the parameter that contain more than 5 letters. (A word is defined as a contiguous sequence of letters.)

LANGUAGE: JAVA CHALLENGE: Write a static method, getBigWords, that gets a single String parameter and returns an array whose elements are the words in the parameter that contain more than 5 letters. (A word is defined as a contiguous sequence of letters.) EXAMPLE: So, if the String argument passed to the method was “There are...

This content requires that you purchase additional access. The price is $2.99 or free for our Make Life Easier and 30 Days - Not Recurring members.

Purchase this Content ($2.99) Choose a Membership Level

Read More