Sunday, September 28, 2014

help with java assignments for class?
































































I am having trouble figuring out why java is giving me an error for the symbols. I will post the errors below the code.
































































































Java Code:






































































import java.util.Scanner;


public class ShelbyHarms_3_02 {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);

double s = 0; //Semi-Perimeter
double x = 0; // Perimeter of triangle
double area = 0; //Area of triangle
double a, b, c = 0; //Input sides of triangle

//Input lengths of triangle
System.out.print("Please enter triangle side a: ");
a = console.nextDouble();

System.out.print("Please enter triangle side b: ");
b = console.nextDouble();

System.out.print("Please enter triangle side c: ");
c = console.nextDouble();

}

//Calculations for area and perimeter
public static double triangleArea (double a, double b, double c) {
s = (a + b + c)/2.0;
x = ((s) * (s-a) * (s-b) * (s-c));
area = Math.sqrt(x);

return area;

//Output the results
System.out.println("Your three triangle lengths are: " + '\n' + a +
'\n' + b + '\n' + c);
System.out.println("The area of your triangle is: " +
triangleArea(a, b, c));

} // End main()
} // End class




































































My errors are:































ShelbyHarms_3_02.java:38: error: cannot find symbol































































s = (a + b + c)/2.0;































































^































































symbol: variable s































































location: class ShelbyHarms_3_02































































ShelbyHarms_3_02.java:39: error: cannot find symbol































































x = ((s) * (s-a) * (s-b) * (s-c));































































^































































symbol: variable x































































location: class ShelbyHarms_3_02































































ShelbyHarms_3_02.java:39: error: cannot find symbol































































x = ((s) * (s-a) * (s-b) * (s-c));































































^































































symbol: variable s































































location: class ShelbyHarms_3_02































































ShelbyHarms_3_02.java:39: error: illegal start of type































































x = ((s) * (s-a) * (s-b) * (s-c));































































^































































ShelbyHarms_3_02.java:39: error: cannot find symbol































































x = ((s) * (s-a) * (s-b) * (s-c));































































^































































symbol: variable s































































location: class ShelbyHarms_3_02































































ShelbyHarms_3_02.java:39: error: cannot find symbol































































x = ((s) * (s-a) * (s-b) * (s-c));































































^































































symbol: variable s































































location: class ShelbyHarms_3_02































































ShelbyHarms_3_02.java:39: error: cannot find symbol































































x = ((s) * (s-a) * (s-b) * (s-c));































































^































































symbol: variable s































































location: class ShelbyHarms_3_02































































ShelbyHarms_3_02.java:40: error: cannot find symbol































































area = Math.sqrt(x);































































^































































symbol: variable area































































location: class ShelbyHarms_3_02































































ShelbyHarms_3_02.java:40: error: cannot find symbol































































area = Math.sqrt(x);































































^































































symbol: variable x































































location: class ShelbyHarms_3_02































































ShelbyHarms_3_02.java:42: error: cannot find symbol































































return area;































































^































































symbol: variable area































































location: class ShelbyHarms_3_02































































10 errors































































































































No comments:

Post a Comment