Write an algorithm (pseudo code OR flowchart) and java program to input the radius and length of a cylinder and computes its
volume using the following formulas:
area = radius * radius * 3.14159
volume = area * length
Solution ( Java Program)
import java.util.Scanner;
public class lab1q1 {
public static void main(String[] args) {
// TODO, add your application code
Scanner input = new Scanner(System.in);
System.out.println("Please enter radius and length");
double radius = input.nextDouble();
double length = input.nextDouble();
double area, volume;
area = radius * radius * 3.14159;
volume = area * length;
System.out.println("Volume =");
System.out.println(volume);
}
}
No comments:
Post a Comment