Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The editing window below includes a custom class called Calculator. Develop the Calculator class to calculate values in custom methods, using data received from the

The editing window below includes a custom class called "Calculator". Develop the Calculator class to calculate values in custom methods, using data received from the Main() method (which you also must develop).

  1. In Main(), declare three integer variables: firstNum, secondNum and output.
  2. Prompt the user with the text "Enter the first value:", and store that value in firstNum.
  3. Prompt the user with the text "Enter the second value:", and store that value in secondNum.
  4. Declare an instance of the Calculator class so it can be used as an object later in the program code.
  5. Make a custom method within the Calculator class (the lower one) called "Multiply", with two incoming integer parameters called "first" and "second").
  6. In the Multiply method, write code that will multiply the first incoming parameter ("first") times the second incoming parameter ("second") and return the result. (Tip: Create an integer variable called "total" within the method to store the result of the calculation, then send total back with the return command.)
  7. Make additional methods called "Add", "Subtract", and "Divide". Write code within each method to perform the relevant calculation (addition, subtraction, and division).
  8. The customer wants only the Multiplication result to be displayed at this time. (Note: The other three methods will be tested when you submit the project for grading.) From Main(), display the results of the multiplication command in the following way (exactly):
Result: 12 

Test your program and ensure that each calculation produces the expected result.

Important Notes (READ CAREFULLY!):

  1. This program does not require either a loop or an IF statement.
  2. Only the shell of the custom class is provided, so you will need to write the entire methods, including the declaration lines. Be careful to name them according to the instructions (step 6). Any difference in the name will cause the grading algorithm to not see your method. (Tip: A review of the default code from the Unit 2 Lab Assignment may be helpful.)

import java.util.Scanner;

public class LabProgram { public static void main(String[] args) { /* Type code below this line. Make additional lines as needed. */ } // do not delete this line } // do not delete this line

class Calculator { /* Type code below this line. Make additional lines as needed. */

} // do not delete this line

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres the completed code import javautilScanner public class LabProgram public static void mainStrin... 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_2

Step: 3

blur-text-image_3

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

Introduction To Management Science A Modeling And Cases Studies Approach With Spreadsheets

Authors: Frederick S. Hillier, Mark S. Hillier

5th Edition

978-0077825560, 78024064, 9780077498948, 007782556X, 77498941, 978-0078024061

More Books

Students also viewed these Programming questions

Question

e. What are the programs research and clinical focus areas?

Answered: 1 week ago

Question

Subtract the polynomials. (-x+x-5) - (x-x + 5)

Answered: 1 week ago

Question

How would you define the zero vector

Answered: 1 week ago