Question

Java Using NetBean Given a cylinder with radius of 5 and height of 8, write a...

Java Using NetBean

Given a cylinder with radius of 5 and height of 8, write a program to calculate the volume of this cylinder. You need to define a constant value PI in your program.

0 0
Add a comment Improve this question Transcribed image text
Answer #1


import java.util.Scanner;
class Main
{
static final double PI=3.14;//constant defined
public static void main(String args[])
{   

int radius=5,height=8;
double volume=PI*radius*radius*height;
System.out.println("volume of Cylinder is: " +volume);
}//main ends here
}//class ends here

Add a comment
Know the answer?
Add Answer to:
Java Using NetBean Given a cylinder with radius of 5 and height of 8, write a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The volume of a right circular cylinder is calculated by Trh where ris radius and his...

    The volume of a right circular cylinder is calculated by Trh where ris radius and his height Write a user-defined MATLAB function to compute the volume given radius and height. For the function name and arguments use Volume - Volume cylinder (Radius, Height). You do not need to call the function, you need to write the function as is would be in your current folder available to be called from a program. The function will take in the indicated inputs,...

  • Java Programing. Using NetBean Write a program to draw a line connecting two circles. These two...

    Java Programing. Using NetBean Write a program to draw a line connecting two circles. These two circles can be dragged by mouse. And when circles are dragged, the line should be adjusted so that it still connect these two circles (binding property)

  • Write a program that asks the user to input the radius and height of a cylinder...

    Write a program that asks the user to input the radius and height of a cylinder and the unit weight of the material (in pounds per square feet). The program computes the surface area of the cylinder and the total weight of the cylinder. The program uses two functions: One function to read the data from the keyboard, the other function to calculate the surface area and the weight of the cylinder. The weight of the cylinder is printed from...

  • QUESTION 4 Find the surface area of a cylinder with a radius of 3 and a...

    QUESTION 4 Find the surface area of a cylinder with a radius of 3 and a height of 10. The surface area is TT units (Do not use pi in your answer as it is already written with the units above) QUESTION 5 Find the volume of a cone with a radius of 6 and a height of 8. The volume is IT units (Do not use pi in your answer as it is already written with the units above)...

  • using Java The formula to compute the volume of a sphere is: volume = ( 4...

    using Java The formula to compute the volume of a sphere is: volume = ( 4 3 ) π r 3 where r is the radius of the sphere and π is 3.14159. Assume a variable radius has already been declared (type double) and initialized with the value of the radius of a sphere. Write java statements to do the following: Declare a constant PI and initialize it to 3.14159 Declare a variable volume of type double Calculate the volume...

  • Java Programing. Using NetBean Write a program to draw a line connecting two circles. These two circles can be dragged by mouse. And when circles are dragged, the line should be adjusted so that it st...

    Java Programing. Using NetBean Write a program to draw a line connecting two circles. These two circles can be dragged by mouse. And when circles are dragged, the line should be adjusted so that it still connect these two circles (binding property)

  • Write a C program named assignment04.cpp that will ask for and read in a float for...

    Write a C program named assignment04.cpp that will ask for and read in a float for a radius ask for and read in a float for the height each of the following functions will calculate some property of a shape (area, volume, circumference, etc) The functions will accept one or two parameters (radius and/or height) and return the proper calculation. There is no input/output (cin or cout) in the function – just the calculation write the following functions float areaCircle(float...

  • Using MATLAB 18. A cylinder with base radius r and height h is con- structed inside...

    Using MATLAB 18. A cylinder with base radius r and height h is con- structed inside a sphere such that it is in contact with the surface of a sphere, as shown in the figー ure. The radius of the sphere is R- 11 in. (a) Create a polynomial expression for the vol- / >1 ume V of the cylinder in terms of h. (b) Make a plot of V versus h for 0 shs11 in. (c) Using the roots...

  • OOLSVIEW 215710514 (ratected View) Wo CTED VIEW Beca 1. Write a program that reads in the...

    OOLSVIEW 215710514 (ratected View) Wo CTED VIEW Beca 1. Write a program that reads in the radius and length of a cylinder and computes the area and volume using the following formulas area pi radius volume area length your program should have length as integer variable radius as double variable pi as Named Constant It prints the output with maximum 2 decimal digits. If area is greater than 20, it checks if the area is odd or not and prints...

  • Create a Ruby class Cylinder. Each cylinder is characterized by the instance variables radius and height. For this class...

    Create a Ruby class Cylinder. Each cylinder is characterized by the instance variables radius and height. For this class the initializer/constructor and the method volume that returns the volume of the cylinder. For this class the initializer/constructor and the method area that returns the area of cylinder. Create a class Can that inherits properties from the class Cylinder and adds new instance variablescontents(e.g. beer, Pepsi, Coke) and price(real number). Initialize an array of cans and write Ruby code necessary to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT