String implementation Circumference of shapes

Hello, this is dmangru from CSC-117 prof alijamalThis is my attempt at using string implementation, not sure if I went overboard or if this was necessary
mail@pastecode.io avatar
unknown
java
2 years ago
2.9 kB
8
Indexable
Never
// Devin Mangru
// prof Alijamal
// CSC 117
// October 24 2021

/*This Program Lets you pick from 3 diffrent shapes to calculate the circumference of using string 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) 
   {
     /*Decleration input section */
      String square = new String ("You chose square"); 
      String square_side = new String ("Please enter one side");
      String square_circumference = new String ("The circumference of your Square is: ");
      
      String rectangle = new String ("You chose rectangle"); 
      String rectangle_length = new String ("Please enter the length of the Rectangle");
      String rectangle_height = new String ("Please enter the Height of the Rectangle");
      String rectangle_circumference = new String ("The circumference of your Rectangle is: ");
     
      String triangle = new String ("You chose triangle"); 
      String triangle_first_side = new String ("Please enter the first side");
      String triangle_second_side = new String ("Please enter the second side");
      String triangle_third_side = new String ("Please enter the third side");
      String triangle_circumference = new String ("The circumference of your triangle is: ");

    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(square);
            System.out.println(square_side);
            a = input.nextInt();
            circumference = a*4;
            System.out.print(square_circumference + circumference);
  
    break;  
    case 2: System.out.println(rectangle);
            System.out.println(rectangle_length);
            a = input.nextInt();
            System.out.println(rectangle_height);
            b = input.nextInt();
            circumference = 2*(a+b);
            System.out.print(rectangle_circumference + circumference);
  
    break;  
    case 3: System.out.println(triangle);
            System.out.println(triangle_first_side);
            a = input.nextInt();
            System.out.println(triangle_second_side);
            b = input.nextInt();
            System.out.println(triangle_third_side);
            c = input.nextInt();
            circumference = a*b*c;
            System.out.print(triangle_circumference + circumference);
            
        break;
        
        default:
        System.out.println("Invalid number, pick a number that correlates to the given shapes\n***Error***");


            
  }
    
    
    
    
    
    
    
    
    
    
      }

}