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
Can web sites contain copyright material? <br> Yes <br> No
Maru [420]
Yes they can contain copyright
6 0
2 years ago
Read 2 more answers
Create a program that includes a function called toUpperCamelCase that takes a string (consisting of lowercase words and spaces)
astraxan [27]

Answer:

#include<iostream>

using namespace std;

//method to remove the spaces and convert the first character of each word to uppercase

string

toUpperCameICase (string str)

{

string result;

int i, j;

//loop will continue till end

for (i = 0, j = 0; str[i] != '\0'; i++)

{

 if (i == 0)       //condition to convert the first character into uppercase

  {

  if (str[i] >= 'a' && str[i] <= 'z')   //condition for lowercase

  str[i] = str[i] - 32;   //convert to uppercase

  }

if (str[i] == ' ')   //condition for space

  if (str[i + 1] >= 'a' && str[i + 1] <= 'z')   //condition to check whether the character after space is lowercase or not

  str[i + 1] = str[i + 1] - 32;   //convert into uppercase

if (str[i] != ' ')   //condition for non sppace character

  {

  result = result + str[i];   //append the non space character into string

  }

}

//return the string

return (result);

}

//driver program

int main ()

{

string str;

char ch;

//infinite loop

while (1)

{

fflush (stdin);

//cout<< endl;

getline (cin, str);   //read the string

//print the result

//cout<< endl << "Q";

// cin >> ch; //ask user to continue or not

ch = str[0];

if (ch == 'q' || ch == 'Q')   //is user will enter Q then terminatethe loop

  break;

cout << toUpperCameICase (str);

cout << endl;

}

return 0;

}

8 0
3 years ago
A cycle merchant allows 15% discount on the marked price of a bicycle and still he makes a profit
lions [1.4K]

Answer:

The program in Java is as follows:

public class Main{

public static void main(String[] args) {

 double discount_percent = 0.15;

 double discount_amount = 600;

 double profit = 0.20;

 double marked_price = discount_amount/discount_percent;

 double cost_price = marked_price/(1 + profit);

 System.out.println("Marked Price: "+marked_price);

 System.out.println("Cost Price: "+cost_price);

}}

Explanation:

For explanation purpose, let

MP \to Marked Price

\%D \to Percentage discount

D \to Discounted amount

\%P \to Percentage Profit

C \to Cost Price

The marked price (i.e. selling price) is calculated discount using:

MP = \frac{D}{\%D}

The derived formula of the cost price from percentage profit and Marked Price is:

C = \frac{M}{1 + \%P * 100}

So, the explanation is as follows:

The next three lines declare and initialize the given parameters

<em>  double discount_percent = 0.15;</em>

<em>  double discount_amount = 600;</em>

<em>  double profit = 0.20;</em>

Calculate marked price

 double marked_price = discount_amount/discount_percent;

Calculate cost price

 double cost_price = marked_price/(1 + profit);

Print marked price

 System.out.println("Marked Price: "+marked_price);

Print Cost price

 System.out.println("Cost Price: "+cost_price);

3 0
2 years ago
Write a program that reads in an integer, and breaks it into a sequence of individual digits. Display each digit on a separate l
Montano1993 [528]

Answer:

The program in Python is as follows:

num = int(input())

for i in str(num):

   print(int(i))

Explanation:

This gets input for the number

num = int(input())

This converts the number to string and iterates through each element of the string

for i in str(num):

This prints individual digits

   print(int(i))

4 0
2 years ago
What happens to runt frames received by a cisco ethernet switch?
Nikolay [14]

Answer:

thank you sa point labyu stay safe

5 0
2 years ago
Other questions:
  • You have been hired to upgrade a network of 50 computers currently connected to 10 mbps hubs. this long-overdue upgrade is neces
    12·1 answer
  • In this problem we consider sending real-time voice from Host A to Host B over a packet-switched network (VoIP). Host A converts
    12·1 answer
  • Which two encryption protocols might be used to provide secure transmissions for browser and web server communications?
    14·1 answer
  • Given that two int variables, total and amount, have been declared, write a loop that reads integers into amount and adds all th
    11·1 answer
  • When adopting the use of social media in emergency management, it is important to have
    10·1 answer
  • What is the difference between = and == in terms of java..?
    6·2 answers
  • 50 POINTS!!!!!!!!!!!<br><br> Give at least two examples of how the transport layer is used.
    13·2 answers
  • When browsing using certain browsers, if a page is known to be malicious or using phishing techniques in the past a browser may
    5·1 answer
  • For this activity, you will practice being both proactive and reactive to bugs. Both are necessary to get rid of errors in code.
    5·1 answer
  • What is are the most efficient ways to make a slide presentation?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!