generate functionSat, 06 May 2023

Realizar un programa que calcula el volumen de los siguientes cuerpos geométricos: o Cubo o Pirámide o Cilindro o Cono o Esfera

fun main(args: Array<String>) { val scan = Scanner(System.`in`) var option = 0 do { println("Select an option") println("1. Cube") println("2. Pyramid") println("3. Cylinder") println("4. Cone") println("5. Sphere") println("0. Exit") option = scan.nextInt() if (option != 0) { print("Enter the value of the edge: ") val value = scan.nextFloat() when (option) { 1 -> println("The volume of the Cube is ${cube(value)}") 2 -> println("The volume of the Pyramid is ${pyramid(value)}") 3 -> println("The volume of the Cylinder is ${cylinder(value)}") 4 -> println("The volume of the Cone is ${cone(value)}") 5 -> println("The volume of the Sphere is ${sphere(value)}") } } }

Questions about programming?Chat with your personal AI assistant