I am trying to make a program that will get the area of a Triangle,Rectangle,Circle.
The user picks which shape they want the area of and then inputs the Length/Width/Radius or whatever is needed. Im now stuck. I cannot get the data to print. I have made all the equations in the code. Here is the code.
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author Logan */ import java.util.Scanner; public class area { public static void main(String[] args) { //Declaring Variables. int triHeight, triBase, lengthRect, widthRect, shapeNum; double circRadi; Scanner reader = new Scanner (System.in); //Receiving Input System.out.println ("Which shape do you want area for?"); System.out.println("1 Triangle 2 Circle 3 Rectangle 0 None"); shapeNum = reader.nextInt (); if (shapeNum == 1) { System.out.println("Base of triangle?"); triBase = reader.nextInt (); System.out.println("Height of triangle"); triHeight = reader.nextInt (); } if (shapeNum == 2) { System.out.println("Radius of circle?"); circRadi = reader.nextDouble (); } if (shapeNum == 3) { System.out.println ("Length of rectangle?"); lengthRect = reader.nextInt (); System.out.println("Width of rectangle?"); widthRect = reader.nextInt (); } } public static void areaTriangle(int triBase,int triHeight, int triOutput) { triOutput = (triBase*triHeight)/2; } public static void areaCircle (double circOutput,int circRadi ) { circOutput = (circRadi*Math.PI); } public static void areaRectangle(int rectOutput, int lengthRect, int widthRect) { rectOutput = lengthRect*widthRect; } }