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;  
                    }
                }
                }

                                 }
            }

            }

        }

You can only get to line 17 if number is 1, so having a switch on number at line 17 is pointless. Did you mean number2 ?
The switch on line 15 has only one case - what's the point of that?
Line 18 is invalid - all the code inside a switch has to be in case blocks

I think Drax from Guardians Of The Galaxy would say:

Why is line 17?

That is, it seems odd to place a switch() statement there.

Line 5 has typo: arrg should be arg.
Why have 1 case on line 17? Just remove that.
You only need one case statement below it.
It is like this was entered in one hit instead of debugging as you went. This is not a good way to program - big bang.

identical switch within switch is just wrong, and printing inside swtch ouside any case is not at all nice.

The error is really on line 18, but it is reported on line 17. The switch statement must be followed by case clauses, each with a constant value for comparison. Line 18 is not a case clause, so the compiler reports that the switch statement is malformed. Also, individual cases clauses do not need to be enclosed in { curlly braces }.

The logic of putting one switch statement inside another, comparing the same value, is unclear to me; you should examine exactly what you intended to do here. Because the inner switch statement is inside a clause where the value is already determined to be 1, the first case will only ever be executed and everything else will be skipped.

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.