New to java, Looking for advice
Hello I know this site must get many of this same question But I am in my
first semester of compsci and looking for help with a java program.
import java.util.Scanner;
public class FallPA2
{
static Scanner console = new Scanner(System.in);
public static void main(String [] args)throws Exception
{
double n1,n2,n3; // Defines the input varibales
double perimeter,area,pHalf,sumt; // define varibles used in calculation
/* Explains the program to the user*/
System.out.println("This program will calculate the perimeter and
area of any triangle.");
/* Ask the user for the input */
System.out.println("What is the measure of side one?");
n1 = console.nextDouble();
System.out.println("What is the measure of the second side?");
n2 = console.nextDouble();
System.out.println("What is the measure of the third side?");
n3 = console.nextDouble();
/* Calculations */
perimeter = n1+n2+n3;
pHalf = perimeter/2;
sumt = (pHalf - n1)*(pHalf - n2)*(pHalf - n3);
area = Math.sqrt(pHalf * sumt);
/* Print out the information to the user */
System.out.print("The length of the triangle are: ");
System.out.println(n1 +" ," + n2 +" ," + n3 + ".") ;
System.out.print("The perimeter of the triangle is ");
System.out.println( perimeter + ".");
System.out.println("The area of the triangle is " + area + ".");
System.out.println("Program complete.");
}
}
This is the program in question, when I run the main method every thing
works fine but When I compile the whole thing, nothing happens. There are
no compile errors but nothing happen in the console.
Can any one offer any help?
Thank you
No comments:
Post a Comment