package de.extrema.java;
import java.util.Scanner;
public class Pogramm {
public static void main(String arrg[]) {
try (Scanner scanner = new Scanner(System.in)) {
double a , b , r , A , h;
int number2;
int number;
System.out.println("Körper: ");
System.out.println("Deine Wahl: ");
number = scanner.nextInt();
number2 = scanner.nextInt();
switch(number) {
case 1:{
switch(number) {
System.out.println("Viereck: 1 Kreis: 2 Dreieck: 3 Trapez: 4 ");
case 1:{
System.out.println("a: ");
a = scanner.nextDouble();
System.out.println("b(a): ");
b = scanner.nextDouble();
A = a * b;
System.out.println("Fläche des Vierecks= " + A);
break;
}
case 2:{
System.out.println("r: ");
r = scanner.nextDouble();
A = Math.PI * r * r;
System.out.println("Fläche des Kreises= " + A);
break;
}
case 3:{
System.out.println("a: ");
a = scanner.nextDouble();
System.out.println("b: ");
b = scanner.nextDouble();
A = 0.5 * a * b;
System.out.println("Fläche des Dreiecks: " + A);
break;
}
case 4:{
System.out.println("a: ");
a = scanner.nextDouble();
System.out.println("b: ");
b = scanner.nextDouble();
System.out.println("h: ");
h = scanner.nextDouble();
A = (a + b)* h / 2;
System.out.println("Fläche des Trapezes: " +A);
break;
}
}
}
}
}
}
}
nxcx 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
rproffitt 2,662 "Nothing to see here." Moderator
wwwalker 49 Newbie Poster
DGPickett 20 Newbie Poster
Nutster 58 Newbie Poster
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.