Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a java program to implement a calculator for operating on arrays. Calculator -arr1: int array -arr2: int array -length: int +Calculator(int) +Calculate(Calculator obj, char

Write a java program to implement a calculator for operating on arrays.

Calculator

-arr1: int array

-arr2: int array

-length: int

+Calculator(int)

+Calculate(Calculator obj, char c): int[]

+inputArr1():void

+inputArr2():void

+Getters and setters.

You need to create an object from the Calculator class in your test class. Then, you need to fill arrays of the object with the user inputs. Then, you need to take and operator from the user to define which operations to be done. It is needed to do exception handing for same cases: IndexOutOfBounds exception: Inside InputArr1() and InputArr2() functions, you need to make sure that arrays are not going out of bounds by handling the IndexOutOfBounds exception. NumberFormatException: Inside InputArr1() and InputArr2() functions, you need to check if inputs are in correct format(integer). Arithmetic Exception: Inside Calculate() function, you need to handle arithmetic exception in case a number is divided by zero. Throw Exception: Inside Calculate() function, you need to check if arrays lengths are equal. If they are not the equal, then you need to throw an exception. In your test class there will be a menu driven process that program will contuniue as long as user does not input exit

image text in transcribed

length of first number set: 4 25 24 35 58 1st set entered: 25 24 35 58 length of second number set: 4 5 6 45 29 2nd set entered: 5 6 45 29 choose operation: + 30 30 80' 87 choose operation: - 20 18 -10 29 choose operation: * 125 144 1575 1682 choose operation: / 5 4 0.777778 2 choose operation: exit

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

Step: 3

blur-text-image

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

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

Have ground rules been established for the team?

Answered: 1 week ago

Question

a. How are members selected to join the team?

Answered: 1 week ago

Question

b. Will new members be welcomed?

Answered: 1 week ago