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
Andru [333]
3 years ago
11

Write a function ""volCylinder"" that takes twofloats""r""for the radius and ""h""for the height of the cylinder and returnsthe

volumeof the cylinder. You can check the Wikipedia page to learn about volume calculation of the cylinders:
Computers and Technology
2 answers:
shutvik [7]3 years ago
8 0

Answer:

   public static double volCylinder(double r, double h){

       double volCylinder = Math.PI*(r*r)*h;

       return volCylinder;

   }

Explanation:

Using Java programming language

The function (method) is declared to accept two double parameters for radius and height

Using the formula Vol = \pi r^{2} h The volume is calculated and returned.

See a complete java code with a main method below

<em>public class num7 {</em>

<em>    public static double volCylinder(double r, double h){</em>

<em>        double volCylinder = Math.PI*(r*r)*h;</em>

<em>        return volCylinder;</em>

<em />

<em>    }</em>

<em>    public static void main(String[] args) {</em>

<em>    double radius =5.1;</em>

<em>    double height = 7.1;</em>

<em>        System.out.println("The volume of the cylinder is: "+volCylinder(radius,height));</em>

<em>    }</em>

<em>}</em>

Mandarinka [93]3 years ago
4 0

Answer:

def volCylinder(r, h):

   return 3.14 * r * r * h;    

radius = float(input("Enter the radius: "))

height = float(input("Enter the height: "))

print("The volume of the cylinder is: "+ str(volCylinder(radius, height)))

Explanation:

- Inside the function, calculate the volume of the cylinder using the formula and return the result.

- Then, take inputs from the user for radius and height as float numbers

- Call the function and print the result

You might be interested in
Fungsi radio adalah..?
malfutka [58]

Answer:

lebih lanjut bahwa radio mempunyai fungsi sebagaimana media- media lain yaitu memberikan informasi/to inform, memberikan pendidikan/to educate, memberikan hiburan/to intertain, fungsi memengaruhi/to influence, dan fungsi pengawasan to control.

<h2>translate;</h2>

Furthermore, radio has a function like other media, namely to provide information/to inform, provide education/to educate, provide entertainment/to intertain, function to influence/to influence, and control function to contact.

Explanation:

8 0
2 years ago
Two cars A and B leave an intersection at the same time. Car A travels west at an average speed of x miles per hour and car B tr
drek231 [11]

Answer:

Here is the C++ program:

#include <iostream>  // to use input output functions

#include <cmath>  // to use math functions like sqrt()

#include <iomanip>  //to use setprecision method

using namespace std;   //to access objects like cin cout

int main ()  {  //start of main function

  double speedA;  //double type variable to store average speed of car A

  double speedB;  //double type variable to store average speed of car B

  int hour;  //int type variable to hold hour part of elapsed time

  int minutes;  //int type variable to hold minutes part of elapsed time

  double shortDistance;  // double type variable to store the result of shortest distance between car A and B

  double distanceA;  //stores the distance of carA

  double distanceB;  //stores the distance of carB

  double mins,hours;   //used to convert the elapsed time

cout << "Enter average speed of car A: " << endl;  //prompt user to enter the average speed of car A

cin >> speedA;   //reads the input value of average speed of car A from user

cout << "Enter average speed of car B: " << endl ;  //prompt user to enter the average speed of car B

cin >> speedB;   //reads the input value of average speed of car A from user

cout << "Enter elapsed time (in hours and minutes, separated by a space): " << endl;  //prompts user to enter elapsed time

cin>> hour >> minutes;    //reads elapsed time in hours and minutes

  mins = hour * 60;  //computes the minutes using value of hour

  hours = (minutes+mins)/60;     //computes hours using minutes and mins

distanceA = speedA * (hours);  // computes distance of car A

distanceB = speedB * (hours);   //computes distance of car B

   shortDistance =sqrt((distanceA * distanceA) + (distanceB * distanceB));   //computes shortest distance using formula √[(distanceA)² + (distanceB)²)]

cout << "The (shortest) distance between the cars is: "<<fixed<<setprecision(2)<<shortDistance;

//display the resultant value of shortDistance up to 2 decimal places

Explanation:

I will explain the program with an examples:

Let us suppose that the average speeds of cars are:

speedA = 70

speedB = 55

Elapsed time in hours and minutes:

hour = 2

minutes = 30

After taking these input values the program control moves to the statement:

mins = hour * 60;  

This becomes

mins = 2 * 60

mins = 120

Next

hours = (minutes+mins)/60;

hours = (30 + 120) / 60

         = 150/60

hours = 2.5

Now the next two statements compute distance of the cars:

distanceA = speedA * (hours);  

this becomes

distanceA = 70 * (2.5)

distanceA = 175

distanceB = speedB * (hours);

distanceB = 55 * (2.5)

distanceB = 137.5

Next the shortest distance between car A and car B is computed:

shortDistance = sqrt((distanceA * distanceA) + (distanceB * distanceB));

shortDistance = sqrt((175 * 175) + (137.5 * 137.5))

                        = sqrt(30625 + 18906.25)

                        = sqrt(49531.25)

                        =  222.556173

shortDistance =  222.56

 

Hence the output is:

The (shortest) distance between the cars is: 222.56        

3 0
3 years ago
An abstraction is a simplified representation of something that is more complex. Decimal numbers were a useful abstraction in th
Blababa [14]

What was the content of the lesson? It is hard to answer a question we need context on.

6 0
2 years ago
Let's get into some looping. Sometimes it is nice to generate your own data. Now let's take our first stab at it.
valkas [14]

Answer:

55

Explanation:

3 0
3 years ago
Taking a recipe and breaking it down into its individual sections, like ingredients, preparation, cooking instructions, and nutr
Anna11 [10]
1.For each of the following, give the name of an element from Period 4 (potassium to krypton), which matches the description.
Elements may be used once, more than once or not all.. Single line text.
(1 Point)
an element that reacts with water to produce a lilac flame

2.For each of the following, give the name of an element from Period 4 (potassium to krypton), which matches the description.
Elements may be used once, more than once or not all.. Single line text.
(1 Point)
an element used as an inert atmosphere

3.For each of the following, give the name of an element from Period 4 (potassium to krypton), which matches the description.
Elements may be used once, more than once or not all.. Single line text.
(1 Point)
an element that has a valency of 3

4.Write a balanced chemical equation for the reaction between potassium and water. (Non-anonymous question). .
(1 Point)

Upload file
File number limit: 1Single file size limit: 10MBAllowed file types: Word, Excel, PPT, PDF, Image, Video, Audio
5.For each of the following, give the name of an element from Period 4 (potassium to krypton), which matches the description.
Elements may be used once, more than once or not all.. Single line text.
(1 Point)
an element with a fixed valency of 2 that not is not in group 2
8 0
3 years ago
Read 2 more answers
Other questions:
  • A ___________ is an algorithm for which it is computationally infeasible to find either (a) a data object that maps to a pre-spe
    5·1 answer
  • Many malware attacks are ____ attacks, which involve more than one type of malware and/or more than one type of transmission met
    6·1 answer
  • Ally typed a business letters she most likely used a
    5·1 answer
  • You can precede a subquery with the ___ operator to create a conditiion that is true if one or more rows are obstained when the
    10·1 answer
  • Anna is making a presentation on the solar system. She wants to emphasize the planet names as they appear one by one on the pres
    11·1 answer
  • Need help please. this effect my technology
    15·1 answer
  • Which of the following translates packets so that the node can understand them once they enter through a port?
    5·2 answers
  • A digital footprint is .
    7·1 answer
  • How does a passive attack differ from an active attack?
    8·1 answer
  • Which of the following shows data conversion taking place?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!