Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose we are given a class ETAClass. This given class has a class method someMethod() which accepts no input argument and returns no value, but

image text in transcribed

Suppose we are given a class ETAClass. This given class has a class method someMethod() which accepts no input argument and returns no value, but potentially produces exception of a "special exception type SomeException back to the caller. the details of what this class and method actually do. Answer the coming questions. a) Write a public class WONGvg (named related to your surname) in Java for averaging numbers, so that the following program codes could be run as expected with this new class. (Use your own surname, suppose the student surname is WONG in the example program code below) o Body of all constructors and methods can have no more than 2 statements. o Execution of the codes below would display on console the average result: 5.5 WONGvg aETA = new WONGavg(); WONGvg BETA = new WONGavg(2.2, 8.8); aETA.setAvg ( bETA ); System.out.println( aETA.getAvg () ); [10 marks) o o b) Write a new class method into the new class in a) part, example named chanSquare(), which fulfils the following: O Name this method according to your surname (Use your own surname, suppose the student surname is CHAN in the above example) The method accepts one input argument of string, and return no value. The method first calls the given method someMethod(). The method then attempts to convert the input string to int type integer with wrapper class Integer, and display the square value of this int result on console if successfully done in a similar format: 23 square is 529(* Suppose the input string is "23") as sample output below. This also potentially produces exception of NumberFormatException Sample Console Display Output 23 square is 529 The method handles all possible exceptions, which simply displays proper message on console similar to the following format based on the exception type, as sample outpul below: Exception: Type (* Suppose exception Number FormatException) COP Cor Sample Console Display Output Exception: Type NumberFormatException) LG

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions

Question

1. PricewaterhouseCoopers

Answered: 1 week ago

Question

3. SCC Soft Computer

Answered: 1 week ago