/* Interactive Average Program
      This program asks the user to input three real numbers
      to serve as the sides of a triangle. The program then calculates 
      the perimeter and area of the triangle using Heron's formula and prints the results.
     Michael Novitsky
     Program #2, CS 1050, Section 1
     jGRASP IDE, Toshiba Sattelite windows 8 64-bit
     Baleful - harmful, ominous, causing evil.
     "Inside each of us is the seed of both good and evil. It's a constant
     struggle as to which one will win. And one cannot exist without the other."
     --- Eric Victor Burdon (b. 1941)     
     */
     
     import java.util.Scanner;
     import java.lang.Math;
     
     public class MichaelNovitsky_1_02 {
     
         public static void main (String [] args) {
         
            Scanner scnr = new Scanner(System.in);                      
            double side1 = 0.0;     // Input value 1 out of 3
            double side2 = 0.0;     // Input value 2 out of 3
            double side3 = 0.0;     // Input value 3 out of 3
            double perimeter = 0.0; // Sum of the input values
            double area = 0.0;      // Area of the triangle
            double periHalf = 0.0;  // Half of the perimeter
            
         System.out.println("This program asks for the input of 3 lengths ");
         System.out.println("of the sides of a triangle. The outputs will be "); 
         System.out.println("the area and perimeter of the triangle, respectively.");
             
         // Input the three side lengths of the triangle
         System.out.print("Enter the length of side one: ");
         side1 = scnr.nextDouble();
         System.out.print("Enter the length of side two: ");
         side2 = scnr.nextDouble();
         System.out.print("Enter the length of side three: ");
         side3 = scnr.nextDouble();
         
         // Calculate the perimeter of the triangle
         perimeter = side1 + side2 + side3;
         
         // use half of the perimeter to calculate the area 
         periHalf = perimeter / 2.0;
         
         // Calculate the area of the triangle using Heron's formula
         area = Math.sqrt(periHalf * ((periHalf - side1) * 
            (periHalf - side2) * (periHalf - side3)));
         
         // Output the results
         System.out.println("The lengths of the sides of the triangle are " 
         + side1 + ", " + side2 + ", and " + side3 + ".");
         System.out.print("The perimeter of " + side1);
         System.out.println(" plus " + side2 + " plus " + side3 + " equals " 
            + perimeter + ".");
         System.out.println("The area of the respective triangle is equal to " 
            + area + ".");
         System.out.print("Michael Novitsky");
         
         } // End main
       } // End class
