Hello,

Like the title says I'm very, very new at java. I started with finding the area of a triangle, but now I'm trying to ask a user what kind of shape they want the area for, then ask questions to get the area. I can't figure out how to take the shape a person types to go to a certain case. It also says shape hasn't been initialized. I don't know how to do that. I've tried googling, but I really can't figure it out. Thanks for the help in advance.

EDIT: Please ignore lack of calculations in cases... unless that's the problem

import java.util.Scanner; public class TriangleArea { static Scanner sc = new Scanner(System.in); public static void main(String[] args){ char shape; String text = "Do you want to find the area of a triangle, square, rectangle, or trapezoid?"; System.out.print("Text"); switch(shape){ case '1': double base; double height; System.out.print("The base of the triangle is: "); base = sc.nextDouble(); System.out.print("The height of the triangle is: "); height = sc.nextDouble(); double Area1 = base * height; double Area2 = Area1 / 2; System.out.println("The area of the triangle is: " + Area2); case '2': double base1; double height1; System.out.print("The base of the square is: "); base1 = sc.nextDouble(); System.out.print("The height of the square is: "); height1 = sc.nextDouble(); double Area = base1 * height1; System.out.println("The area of the square is: "); case '3': double base2; double height2; System.out.print("The base of the rectangle is: "); base2 = sc.nextDouble(); System.out.print("The height of the rectangle is:"); height2 = sc.nextDouble(); System.out.println("The area of the rectangle is:"); case '4': double base3; double base4; double height3; System.out.print("One side of the trapezoid is: "); base3 = sc.nextDouble(); System.out.print("Another side of the trapezoid is: "); base4 = sc.nextDouble(); System.out.print("The height of the trapezoid is: "); height3 = sc.nextDouble(); System.out.println("The area of the trapezois is: "); default : System.out.println("Invalid shape"); } } }