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
kap26 [50]
3 years ago
14

What method of the Math object can be used to return the largest value from the values that are passed to it?

Computers and Technology
1 answer:
miss Akunina [59]3 years ago
7 0

Answer:

the Math.max() method

Explanation:

The java.lang.* package contains all the essential components needed for a JAVA program which involves numbers and all the operations done on the numericals.

The java.lang.math class contains all the methods needed to perform mathematical operations on numerical values.

All the methods in the question are discussed below with examples.  

Math.max() method

java.lang.Math.max(double/ int/ float a, double/ int/ float b)

This method returns the highest value from among the parameters passed to it.

The syntax for the above is  

Numbers can be integers, float and double or long. The return type is the same as the parameters.

Two values to be compared are passed as arguments and the higher value of them is returned.

This function also accepts negative integers as parameters.

Math.max(-9, -2);

Gives -2 as the output.

Math.max(0.34, 0.45)

Gives 0.45 as the output.

Math.ceil() method

java.lang.Math.ceil(double/ int/ float a)  

This method returns the nearest greater whole number for the given number.

Integer parameter returns an integer number.

Math.ceil(7);

Gives 7 as the output.

Decimal number will return the nearest higher integer.

Math.ceil(8.7);

Gives 9.0 as the output.

Math.ceil(-0.34)

Gives -0 as the output.

Math.pow() method

java.lang.Math.pow(double/ float/ int a, double/ float/ int b)

The above method returns the result of a raise to the power of b.

The first parameter is the base while the second parameter forms the exponent.

Math.pow( 2.3,  4.5 );

This calculates (2.3)^4.5.

Gives 42.44‬ as the output.

Math.pow( 2, 3 );

This calculates the value of 2^3.

Gives 8 as the output.

Math.abs() method  

java.lang.Math.abs(double a)

This method returns non-negative value of the numerical parameter passed to it. Absolute of a number does not changes its value but changes the sign of a negative number. It returns the positive or negation of the negative input number.

Math.abs(-0.1234)

Gives 0.1234 as the output.

Math.abs(12.34)

Gives 12.34 as the output.

These methods require java.lang.Math to be imported in the program.

You might be interested in
Define a method calcPyramidVolume with double data type parameters baseLength, baseWidth, and pyramidHeight, that returns as a d
Rudik [331]

Answer:

import java.io.*;

public class Main {

   public static void main(String[] args) throws IOException {

       double baseLength = 0, baseWidth = 0, pyramidHeight = 0;

       Object[] volume;

       volume = calcPyramidVolume(baseLength, baseWidth, pyramidHeight);

   }

   public static Object[] calcPyramidVolume(double baseLength, double baseWidth, double pyramidHeight) {

       double area = calcBaseArea(baseLength, baseWidth);

       double volume = baseLength * baseWidth * pyramidHeight;

       return new Object[]{volume, area};

   }

   public static double calcBaseArea(double length, double width) {

       return length * width;

   }

}

Explanation:

The problem is flawed because it is completely inefficient for one to create two separate methods to calculate the volume and the area when they can be done at once.

The second problem is that it was never specified whether to return something from the calcBaseArea method.

I assumed it required it, so it is not advisable to initiate the method as a double, but rather create it as an Object so that it can return two values: the volume and the area.

6 0
2 years ago
Which task can be completed with the Template Organizer?
spin [16.1K]

Answer:

B is the answer

Explanation:

i just got it right

8 0
2 years ago
Read 2 more answers
I NEED HELP!! What is the portrait mode?
Rashid [163]

Answer:

A its achromatically save your file

5 0
2 years ago
Read 2 more answers
PLEASE HELP!!! THIS IS DUE TODAY!! WILL MARK BRAINLIEST!!
noname [10]

Answer:

1. Respecting rules and cookies while browsing a website.

2. Being kind and properly following the requirements the owner asks you to follow. Reporting any sort of comment or image that is hurtful/harmful.

Explanation:

1. By the rules and cookies for a website, you ensure the safety of your device  and are not putting any information at risk.

2.  Cyberbullying is a huge issue and you can reduce cyberbullying with the simple steps of being kind and respecting others.

Conclusion:

These rules are examples of good digital citizenship and following them will benefit you and your peers greatly.  

8 0
3 years ago
Read 2 more answers
Write a program that creates a Date object, sets its elapsed time to 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10
Lady bird [3.3K]

Answer:

Explanation:

The following Java program creates various Date objects for each one of the provided milliseconds in the question. Then it calls the toString() method on each one. The last two milliseconds were not included because as a long variable they are too big for the Date object to accept. The code has been tested and the output is shown in the image below.

import java.util.Date;

class Brainly {

   public static void main(String[] args) {

       Date date = new Date();

       date.setTime(10000);

       System.out.println(date.toString());

       Date date2 = new Date();

       date2.setTime(100000);

       System.out.println(date2.toString());

       Date date3 = new Date();

       date3.setTime(1000000);

       System.out.println(date3.toString());

       Date date4 = new Date();

       date4.setTime(10000000);

       System.out.println(date4.toString());

       Date date5 = new Date();

       date5.setTime(100000000);

       System.out.println(date5.toString());

       Date date6 = new Date();

       date6.setTime(1000000000);

       System.out.println(date6.toString());

   }

}

3 0
2 years ago
Other questions:
  • State one advantage of organising data into columns and rows
    11·1 answer
  • Which cisco ios command is used to display the current ospf neighbors and their rids?
    11·1 answer
  • Select the correct answer. Steve wants to change shooting and exposure settings while on his photo shoot. Which camera part will
    7·2 answers
  • A pair of single quotes ' will prevent the shell from interpreting any special character. True or False
    15·1 answer
  • Which two technologies support the building of single-page applications? and are two technologies helpful in building single pag
    12·1 answer
  • The natural language convention used to represent ip addresses is called the:
    15·1 answer
  • Help with this quiz question thank you!
    12·2 answers
  • Even though jdoe and jrock have the same password (i.e., hacker), their password hashes in the /etc/shadow file are different. W
    15·1 answer
  • Where did the name "QWERTY" come from?​
    9·1 answer
  • Have the javascript function CountingMinutes(str) take the str parameter being passed which will be two times (each properly for
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!