1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
krek1111 [17]
3 years ago
9

Write the class Calculator including: a function called addthat takes two parameters containing double values and returns their

sum a function called subtractthat takes two parameters containing double values and returns their difference (subtract the second from the first) a function called multiply that takes two parameters containing double values and returns their product a function called divide that takes two parameters containing double values and returns the value of the first divided by the second. If the second number is a zero, do not divide, and return "You can't divide by zero!"
Computers and Technology
1 answer:
patriot [66]3 years ago
5 0

Answer:

public class Calculator {

       public double add(int a, int b){

       return a+b;

   }

   public double substract(int a, int b){

       return a-b;

   }

   public double multiply(int a, int b){

       return a*b;

   }

   public double divide(int a, int b){

       if(b>0){

           return a/b;

       }

       else{

           System.out.println("Cannot divide by zero");

       }

       return -1;

   }    

}

Explanation:

  • Using Java Programming Language, the class Calculator is created. There are no fields (Instance variables) and no constructors since these are not required by the question.
  • Four methods (functions) are created:  add, substract, multiply and divide as specified in the question.
  • Note the use of the if statement in the divide() to handle case of illegal division (by 0)

You might be interested in
What is the only true way to wipe out every possibility of the virus?
const2013 [10]

Answer: Wipe it completely clean.

Explanation: The only true way to wipe out a possible virus is to wipe a computer completely clean. When you wipe the computer clean, you are starting from scratch and have a better chance of not receiving another virus moving forward.

3 0
4 years ago
How does an Ac Machine work
Pani-rosa [81]

Answer:

In a split system, the compressor condenses and circulates the refrigerant through the outdoor unit, changing it from a gas to a liquid. The liquid is then forced through the indoor evaporator coil or cooling compartment. The indoor unit's fan circulates the inside air to pass across the evaporator fins.

Explanation:

(hope this helps)

6 0
3 years ago
Henry is having a problem with the electrical system on his current laptop. The battery for the laptop will not charge. Henry to
Juliette [100K]

Answer:

There is a short circuit in a component in the power circuit.

Explanation:

The power circuit in a computer system, regulates, rectifies and steps down power and voltage entering the main motherboard.

When a power surge capable of damaging the motherboard occurs, A component in the power circuit is shorted, not allowing the dangerous power to pass.

This can be troubleshooted by passing a high current, since the shorted component has a high emf. It over heats and is detected and changed.

4 0
4 years ago
What does the term hardware refer to?
Jobisdone [24]

Answer:

The physical components that a computer is made of

Explanation:

as u can see these components and u can repaire these components if they got damaged

6 0
3 years ago
Consider the expression 3 * 2 ^ 2 < 16 5 AndAlso 100 / 10 * 2 > 15 - 3. Which operation is performed second?
miss Akunina [59]

Answer:

In the first expression

3 * 4 will be performed second.

In the second expression

10* 2  will be performed second.

Explanation:

In many programming language, there is an operator precedence where the operator (e.g. +, - , * , / etc) will be executed following a specific order. For example, the operator ^ which denotes power will always be executed prior to * or /    and if / and * exist in the same expression, the operator positioned at the left will be executed first.

Hence, in the expression 3*2^2 < 16 , 2 will be powered to 2 (2^2) first and then only multiplied with 3.

In the expression 100 / 10 * 2 > 15 - 3,  100 will be divided by 10 and then only multiplied with 2.

7 0
4 years ago
Other questions:
  • If Maya wants to access a view that would control multiple slides within a presentation, which view should she utilize? Master v
    9·1 answer
  • Tim is in charge of the upcoming interschool baketball tournamnent. He wants to arrange all of the teams and their members in al
    15·1 answer
  • When using the strcat function, you must be careful not to overwrite the bounds of an array?
    5·1 answer
  • A call center company wants to implement a domain policy primarily for its shift workers. The call center has large groups with
    11·1 answer
  • _______ are special incentives or excitement-building programs that encourage consumers to purchase a particular product, often
    7·1 answer
  • When doing black and white photography, which file format should you use if possible? JPEG TIFF PNG RAW
    11·2 answers
  • 1.which of the following CANNOT be copyrighted?
    7·1 answer
  • The point of entry from a wireless device to a wired network is performed at a device called a(n) ____________________.
    10·1 answer
  • An array similar to a phone book has 1000 names arranged as names [0], names[1]....names[999]. Nancy wants to search a name X in
    15·1 answer
  • Explain two ways that you can create a header.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!