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
pentagon [3]
3 years ago
10

Write a Java application that uses the Math class to determine the answers for each of the following: a. The square root of 37 b

. The sine and cosine of 300c. The value of the floor, ceiling, and round of 22.8 d. The larger and the smaller of the character ‘D’ and the integer 71 e. A random number between 0 and 20 (Hint: The random() method returns a value between 0 and 1; you want a number that is 20 times larger.) Save the application as MathTest.java.'
Computers and Technology
1 answer:
gayaneshka [121]3 years ago
5 0

Answer:

import java.util.Random;

public class MathTest {

   public static void main(String[] args) {

       int a = 37, b = 300;

       double c = 22.8;

       int max;

       System.out.println("The Square root of 37 is "+ Math.sqrt(a));

       System.out.println("The Sine of 300 is " + Math.sin(b) + " and the cosine is "+ Math.cos(b));

       System.out.println("The Floor, Ceiling and Round Value of 22.8 respectively are "+Math.floor(c)+", "+Math.ceil(c)

               +", "+Math.round(c));

       max = Math.max((int)'D',71);

       System.out.println("The Maximum between D and 71 is " +max );

       Random rand = new Random();

       int RandValue = rand.nextInt(20);

       System.out.println("A random Number between 0 and 20 is "+ RandValue);

   }

}

Explanation:

In order to get the square root of the number 37, the square root function is called by the statement Math.sqrt(a) since the value 37 has been assigned to a. Method calls are also applied to find the cosine, sine, floor, round and ceiling values for the respective variables.

To determine the maximum between the character 'D' and the integer 71, we first cast the character 'D' to an integer using this (int)'D'. Then we make the Method call Math.max( ).

To generate a random variable between 0 and 20, we first make an object of the class Random we use this object to obtain a random number between 0 and 20 by specifying the bound to 20 during the method call.

You might be interested in
if we declare a function as friend of a template class will it be a friend for a particular data type or for all data types of t
suter [353]

Answer:

When we declare a function as a friend of a template class, it means it can access the public, as well as the private and protected members both data variables, and functions of that class. Thus, the friend has access not only to certain data types, but they have access to all the data types of that class. Thus, the function declared as the friend is never deprived of accessing any particular data type of a template class, or any class.

Explanation:

However, you should understand what is template class as well. A template class is the one that is a template and can be transformed into various object code for various data types, that supports all the operators used inside that class or function. We do have the template function. And these behave generically.

7 0
3 years ago
Which describes a design theme in PowerPoint? a set of elements that unify the slides and complement the topic a printed handout
chubhunter [2.5K]

a set of elements that unify the slides and complement the topic

5 0
3 years ago
Read 2 more answers
Was the big blue button thing a good decision or bad?<br> *I think it was a bad idea.
Gala2k [10]

sorry i just got banned so delete this answer plz i was banned and i wanted to see if they unbanned me

8 0
3 years ago
Read 2 more answers
How do i get my laptop to connect to wifi?
SashulF [63]
What type of computer do you have
3 0
3 years ago
You are building a gaming computer and you want to install a dedicated graphics card that has a fast gpu and 1gb of memory onboa
irga5000 [103]
Usually a graphics card would be plugged in manually through a PCI-e express slot on the motherboard. But to give the card enough power (based on how powerful the card is) you would use a 6 pin or an 8 pin power connector.
<span />
5 0
3 years ago
Read 2 more answers
Other questions:
  • Which is the last step in conducting a url research
    11·1 answer
  • which quotation from the story of the fisherman in the Arabian nights' entertainments supports the theme that cleverness trumps
    15·1 answer
  • While reviewing some web page code, you notice that the html is written in all lowercase letters. you are not sure which version
    14·1 answer
  • If I want to copy a worksheet, I right-click the sheet on the bottom of the screen and click what menu item?
    13·1 answer
  • ​ The _____ attribute tells a browser to parse the HTML and JavaScript code together, only pausing to process the script before
    13·1 answer
  • Which text features does this section contain? Check all that apply.
    15·1 answer
  • Lighting matters less in landscapes than in other types of photographs.
    7·1 answer
  • You are working from home and want to discuss a controversial topic. It is important you see the facial expressions of your cowo
    6·2 answers
  • Trees 1. 2. 3. 4. 5.​
    6·1 answer
  • The Internet Protocol Suite consists of the Internet Protocol and _____. a. Transmission Control Protocol b. File Transfer Proto
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!