# Untitled

unknown
java
2 years ago
2.2 kB
10
Indexable
Never
```/*This Program Lets you pick from 3 diffrent shapes to calculate the circumference of using switch statement,
char The user has a choice of picking between a triangle, square and a rectangle.*/

import java.util.Scanner;

class circumference_of_shapes
{

public static void main(String[] args)
{
/*input section*/
char square,triangle,rectangle;
square = 's';
triangle = 't';
rectangle = 'r';
int choice, a, b, c, circumference;
System.out.println("Pick from the following letters to find the circumference.\n Square = s\n Rectangle = r\n Triangle = t");
Scanner input = new Scanner(System.in);
System.out.println("s");
System.out.println("r ");
System.out.println("t");
choice = input.nextInt();

switch(choice) {
case 1: System.out.println("You chose square");
System.out.println("Please enter one side");
a = input.nextInt();
circumference = a*4;
System.out.print("The circumference of your Square is: " + circumference);
break;
case 2: System.out.println("You chose Rectangle");
System.out.println("Please enter the lenght of the Rectangle");
a = input.nextInt();
System.out.println("Please enter the heigth of the Rectangle");
b = input.nextInt();
circumference = 2*(a+b);
System.out.print("The circumference of your Rectangle is: " + circumference);
break;
case 3: System.out.println("You chose triangle");
System.out.println("Please enter the first side");
a = input.nextInt();
System.out.println("Please enter the second side");
b = input.nextInt();
System.out.println("Please enter the third side");
c = input.nextInt();
circumference = a*b*c;
System.out.print("The circumference of your Triangle is: " + circumference);

break;
default:
System.out.println("Invalid char, pick a letter that correlates to the given shapes\n***Error***");

}

}

}```