Assignemnt #97

Code

///colin hinton
///5th period
///Area.java
///1/12/2016

import java.util.Scanner;
public class Area
    {
        public static void main (String[] args)
        {
    
        Scanner kb = new Scanner(System.in);
        System.out.println("Welcome all y'all");
        int choice;
            do
        {
            System.out.println("1) Triangle");
            System.out.println("2) Rectangle");
            System.out.println("3) Square");
            System.out.println("4) Circle");
            System.out.println("5) Quit");
            System.out.print("Which shape:");
            choice = kb.nextInt();
            System.out.println();
            //I made a booboo and got lazy
            if (choice == 4)
            {
                System.out.print("Radius: ");
                int r = kb.nextInt();
                System.out.println("The area is " + Circle(r));
             }
            else if (choice == 2)
            {
                System.out.print("Length: ");
                int l = kb.nextInt();
                System.out.print("Width: ");
                int w = kb.nextInt();
                System.out.println("The area is " + Rectangle(l,w));
            }
            else if (choice == 3)
            {
                System.out.print("Side: ");
                int s = kb.nextInt();
                System.out.println("The area is " + Square(s));
            }
            else if (choice == 1)
            {
                System.out.print("Base: ");
                int b = kb.nextInt();
                System.out.print("Height: ");
                int h = kb.nextInt();
                System.out.println("The area is " + Triangle(b,h));
            }
            else 
            {
                System.out.println("Thanks for playing");
            }
        }while (choice != 5);
        }

            public static double Circle(int r)
            {
                double result;
                result = (Math.PI * Math.pow(r,2) );
                return result;
            }
            public static int Rectangle(int l , int w)
            {
                int result;
                result = (l * w);
                return result;
            }
            public static int Square(int s)
            {
                int result;
                result = (s * s);
                return result;
            }
            public static double Triangle(int b , int h)
            {
                int result;
                result = (b * h) / 2;
                return result;
            }
    }


    
    

Picture of the output

Assignment 1