Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need it ASAP in few hours. Please help. Base Line Java code HW 5 baseline * Write a program that will prompt the user to

Need it ASAP in few hours. Please help.

image text in transcribed

image text in transcribed

image text in transcribed

Base Line Java code

HW 5 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 hw5Baseline { @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); } }

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. Code Requirements: Part 1 -Objective: To calculate the addition, difference, multiplication and division of two -Start with the baseline code, shown in Appendix A, and also included in Canvas under Include the problem statement in the top of the code (copy and paste this document and Include comments in the code -Ask the user to enter two double numbers A and B. (already included in the baseline numbers entered by the user. The code is written is a serial fashion. the files for Homework # 5 enclose in comments) 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 Calculate and print the multiplication of the two numbers A*B. (new code must be Calculate and print the division of the two numbers A/B. (new code must be written) baseline code) 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 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 A and B. (already included in the baseline code) Calculate and print the sum of the two numbers A+B using a first thread. Calculate and print the difference of the two numbers A-B using a second thread. Calculate and print the multiplication of the two numbers A B using a third thread. Calculate and print the division of the two numbers A/B using a 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) -Compress all these files in a folder and attach it in the Canvas assignment corresponding to homework # 5

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

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

Students also viewed these Databases questions