Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java class (name it TwoNumbers) that will manage two numbers. The class should have two integer variables. The class should have the following

Write a Java class (name it TwoNumbers) that will manage two numbers.

The class should have two integer variables.

The class should have the following constructors:

- TwoNumbers();

- TwoNumbers(3, 4);

The first constructor should initialize the class variables to zero.

The second constructor should initialize the class variables to the passed variables.

The class should have the following methods:

- setNumbers(3, 4);

- setFirstNum(3);

- setSecondNum(4);

- getSum();

- getDiff();

- getProd();

The setNumbers(3, 4) method should initialize the two variables of the class to the passed values.

The setFirstNum(3) method should initialize the first variable of the class to the passed value.

The setSecondNum(4) method should initialize the second variable of the class to the passed value.

The getSum() method should return the sum of the two variables in the class.

The getDiff() method should return the difference of the two variables in the class.

The getProd() method should return the product of the two variables in the class.

Also add the method main to call on the methods above.

Please write out the code. No screen shots please.

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

More Books

Students also viewed these Databases questions

Question

4. Describe cultural differences that influence perception

Answered: 1 week ago