How can i write a java program that will read the radius and height of a cylinder and compute the volume using the formulas Area= raduis*raduis*3.14159 and Volume= area*height, and have the program report the area of the bottom of the cylinder and the voulme of the cylinder.

what program are you trying to run ? please make it specified so that we can help you .

This looks like a homework assignment.

You will have to figure out how to create a class with a "main" method, and to run it.

You will have to figure out how to print data to the user (System.out.println), and receive data from the user. (Using a "scanner" is popular.)

The math is trivial. In the program, it will be similar to what you've written above.

you can use this code

import java.util.*;
public class sususususususususus {

	public static Scanner kev=new Scanner(System.in);
	public static void main(String[] args) {
			Scanner kev = new Scanner (System.in);
			//int choice=0 ,again;
			
			System.out.println("Choose what shape do you want [1]cylinder [2]sphere [3]Quit:");
			int k=kev.nextInt();
			
			switch(k){
				case 1:
					cylinder();
					break;
				case 2:
					sphere();
					break;
				case 3:
					System.out.println("You Quit");
					System.out.println("Thank You!!!(^_^)!!!");
					System.exit(k);
					
			}
			
	}
	static void cylinder(){
		System.out.println("Enter radius: ");
		double radius = kev.nextDouble();
		System.out.println("Enter height: ");
		double height = kev.nextDouble();
		System.out.println(radius*radius*Math.PI*height+" square units");
	}
	static void sphere(){
		System.out.println("Enter radius:");
		double radius = kev.nextDouble();
		System.out.println((4/3)*radius*radius*radius*Math.PI+ " Square units");
	}

}
commented: One would have to be really desperate to use such badly written program -4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.