To find the volume of a sphere

Source: Internet
Author: User

Create the Volume class in your project, create a scanner object in the main method of the class to accept the radius of the input, and then calculate the spherical volume based on the spherical volume formula and output it on the console. The code is as follows:

ImportJava.util.Scanner; Public classVolume { Public Static voidMain (string[] args) {//TODO Auto-generated method stubs@SuppressWarnings ("Resource") Scanner Scan=NewScanner (system.in); System.out.println ("Please enter the radius of the sphere:"); DoubleR=scan.nextdouble (); Final Doublepi=3.1415926; Doublevolume=4.0/3.0*pi*r*r*R; System.out.println (The radius of the sphere is: "+R); System.out.println ("PI is:" +PI); System.out.println ("Spherical volume is:" +volume); }}

To find the volume of a sphere

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.