Untitled

 avatar
unknown
java
4 years ago
2.0 kB
6
Indexable
/*This Program Lets you pick from 3 diffrent shapes to calculate the circumference of using switch statement, 
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 int*/
    int choice, a, b, c, circumference;
    Scanner input = new Scanner(System.in);
    System.out.println(" square 1");
    System.out.println(" rectangle 2 ");
    System.out.println(" triangle 3 ");
    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 number, pick a number that correlates to the given shapes\n***Error***");


            
  }
    
    
    
    
    
    
    
    
    
    
      }

}
Editor is loading...