Question: Urgent Solution Required for this program. Java! Purpose: The goal in this assignment is to extend a code that performs the addition and subtraction of

Urgent Solution Required for this program. Java!

Purpose: The goal in this assignment is to extend a code that performs the addition and subtraction of two double numbers to also perform the multiplication and division. Next, modify this code again so that each arithmetic operation is performed in a different thread.

Part 1. -

Objective: To calculate the addition, difference, multiplication and division of two numbers entered by the user. The code is written is a serial fashion. -Start with the baseline code, shown in Appendix A, and also included in Canvas under the files for Homework # 4. -Include the problem statement in the top of the code (copy and paste this document and enclose in comments) -Include comments in the code -Ask the user to enter two double numbers. (already included in the baseline code) - Calculate and print the sum of the two numbers. (already included in the baseline code) - Calculate and print the difference of the two numbers. (already included in the baseline code) - Calculate and print the multiplication of the two numbers. (new code must be written) - Calculate and print the division of the two numbers. (new code must be written)

Part 2. -

Objective: Modify the code from part 1, so that each operation is performed in a different thread. -Include the problem statement in the top of the code (copy and paste this document and enclose in comments) -Include comments in the code -Ask the user to enter two double numbers. (already included in the baseline code) - Calculate and print the sum of the two numbers using a first thread. - Calculate and print the difference of the two numbers using a second thread. - Calculate and print the multiplication of the two numbers using a third thread. - Calculate and print the division of the two numbers using a fourth thread.

Code style: Include comments in your code, use spaces to improve code readability.

Appendix A.

Baseline Java code. /* HW 4 baseline * Write a program that will prompt the user to input double integers. Then perform the addition and subtraction. */ import java.util.concurrent.Executors; import java.util.ArrayList; import java.util.Scanner; public class hw4Baseline { @SuppressWarnings("resource") public static void main(String[] args) { Double number1, number2, sum, diff; // Enter the first number Scanner scanner = new Scanner(System.in);

System.out.println("Please enter the first number:"); number1 = scanner.nextDouble();

// Enter the second number

System.out.println("Please enter the second number:"); number2 = scanner.nextDouble();

// do addition

sum = number1 + number2; System.out.printf("%nThe sum is %f %n", sum);

// do subtraction

diff = number1 - number2; System.out.printf("The difference is %f %n ", diff); } }

Please show your work. Thanks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!