Question: 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
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 -Include the problem statement at 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 A and B. (already included in the baseline code) - Calculate and print the sum A+B of the two numbers. (already included in the baseline code) - Calculate and print the difference of the two numbers A-B. (already included in the baseline code) - Calculate and print the multiplication of the two numbers A*B. (new code must be written) - Calculate and print the division of the two numbers A/B. (new code must be written)
Part 2. -Objective: Write a new code, in which you modify the code from part 1 so that each operation is performed in a different thread. -Include the problem statement at 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 A and B. (already included in the baseline code) - Calculate and print the sum of the two numbers A+B using the first thread. - Calculate and print the difference of the two numbers A-B using the second thread. - Calculate and print the multiplication of the two numbers A*B using the third thread. - Calculate and print the division of the two numbers A/B using the fourth thread.
List of required deliverables -A flowchart or pseudocode must show the logic for each of the two required codes. -A code for part 1(1 java file) -The codes for part 2 (5 java files)
Appendix A. Baseline Java code.
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);
} }
NOTE: -- Give all required deliverables and show step by step solution with screenshots.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
