So I have like 20 errors in here can someone tell me what I did wrong or how I can fix them?
I'm trying to write a program to get the area and perimeter of a triangle.

import java.util.*;


public class myTriangle3 {
//Declarations
   static double area;
   static double perimeter;
   static double side1, side2, side3;

//******************************
//Main
//******************************
   public static void main (String [] args) {
        readData();
        calculations();
        printOutput();
      printHeader();
      printFooter();
    }

//******************************
//readData
//******************************
   public static void readData(){
      System.out.print ("Enter side 1:");
      side1 = scan.nextDouble();
      a = side1;
      System.out.print ("Enter side 2:");
      side2 = scan.nextDouble();
      b = side2;
      System.out.print ("Enter side 3:");
      side3 = scan.nextDouble();
      c = side3;
      s = perimeter/2.0;
      }
//******************************
//calculate
//******************************
   public static void calculations(){
      area = Math.sqrt((s) * (s-a) * (s-b) * (s-c));
      perimeter = a + b + c;
}
//******************************
//printHeader
//******************************
   public static void printHeader(){
        System.out.println("\n**********************");
      System.out.println("       Jason Johnson");
      System.out.println("       CS 1301B");
      System.out.println("       9/5/2014");
      System.out.println("***********************");
   }
//******************************
//printOutput
//******************************
 public static void printOutput(){
      printHeader();
      System.out.println("Side1 is:" + side1);
      System.out.println("Side2 is:" + side2);
      System.out.println("Side3 is:" + side3);
      System.out.println("Area is:" + area);
      System.out.println("Perimeter is:" + perimeter);
      printFooter();
}
//******************************
//printFooter
//******************************
   public static void printFooter(){
   System.out.println("******************  End of Report   ********************");
   System.out.println("******************  Have a good day ********************");
   }
}

Recommended Answers

All 3 Replies

You could've told us what errors you get but from a first look, a/b/c are not deficed in the readData method

After looking thru it again I fixed all the errors it gave me but when I ran the program the area isn't coming out right. It's giving me .0 but I did add the a,b,c, & s.

Show us your latest version of the code

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.