51 lines
1.4 KiB
Plaintext
51 lines
1.4 KiB
Plaintext
import java.util.Scanner;
|
|
import java.text.DecimalFormat;
|
|
|
|
public class Kreisflaeche2 {
|
|
public static DecimalFormat antwortFormat = new DecimalFormat("0.00");
|
|
public static void main(String[] args) {
|
|
|
|
Scanner input = new Scanner(System.in);
|
|
double radius = 0;
|
|
boolean ende = false;
|
|
System.out.print("Radius: ");
|
|
radius = input.nextDouble();
|
|
System.out.println("Rad = " + radius);
|
|
|
|
|
|
while (!ende) {
|
|
System.out.println("Was wollen Sie machen?");
|
|
System.out.println("K, U oder V finden");
|
|
String wahl = input.next();
|
|
switch (wahl) {
|
|
case "K":
|
|
System.out.println("Kreisfläche: " + antwortFormat.format( kreisflaecheB(radius)));
|
|
break;
|
|
case "U":
|
|
System.out.println("Umfang - " + antwortFormat.format( umfang(radius)));
|
|
break;
|
|
case "V":
|
|
System.out.println("Volumen - " + antwortFormat.format( volumen(radius)));
|
|
break;
|
|
default:
|
|
System.out.println("Falsch");
|
|
ende = true;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
public static double kreisflaecheB( double r) {
|
|
return (Math.PI * Math.pow(r,2) );
|
|
}
|
|
|
|
public static double umfang(double r) {
|
|
return (2 * r * Math.PI);
|
|
|
|
}
|
|
public static double volumen(double r) {
|
|
return ((4/3) * Math.PI * Math.pow(r,3));
|
|
|
|
}
|
|
} |