Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This id for intro to java programming problem 11.1 The triangle class, i have the one error that is in bold that i cannot get

This id for intro to java programming problem 11.1 The triangle class, i have the one error that is in bold that i cannot get to go away.

package javaapplicationtriangleclass; import java.util.Scanner; /** * */ public class JavaApplicationTriangleClass {

/** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here //Problem 11.1 Triangle Class Scanner input = new Scanner(System.in);

System.out.print("Enter three sides of the Triangle: "); double side1 = input.nextDouble(); double side2 = input.nextDouble(); double side3 = input.nextDouble();

System.out.print("Enter the color of the Triangle: "); String color = input.next();

System.out.print("Is the Triangle filled? Reply with 'True' or 'False' : "); Boolean filled = input.nextBoolean();

Triangle triangle= new Triangle(side1,side2,side3); triangle.setFilled(filled); triangle.setColor(color); System.out.println(triangle.toString()); System.out.println("The Triangle's Area is: " + triangle.getArea()); System.out.println("The Triangle's Perimeter is: " + triangle.getPerimeter()); System.out.println("The Triangle's Color is: " + triangle.getColor()); System.out.println("Is the Triangle filled: " + triangle.isFilled()); } public class Triangle extends GeometricObject { private double side1 = 1.0; private double side2 = 1.0; private double side3 = 1.0;

public Triangle() { }

public Triangle(double side1, double side2, double side3) { this.side1 = side1; this.side2 = side2; this.side3 = side3; }

public double setSide1() { return side1; }

public double setSide2() { return side2; }

public double setSide3() { return side3; } public double getSide1() { return side1; }

public double getSide2() { return side2; }

public double getSide3() { return side3; }

public void setSide1(double side1) { this.side1 = side1; }

public void setSide2(double side2) { this.side2 = side2; }

public void setSide3(double side3) { this.side3 = side2; }

public double getArea() { return (side1 + side2 + side3) / 2; }

public double getPerimeter() { return side1 + side2 + side3; } /** * * @return */ @Override public String toString() { return "Triangle: Side 1 = " + side1 + " Side 2 = " + side2 + " Side 3 = " + side3; } } }

In another file is the geometric object class that is below:

package javaapplicationtriangleclass;

/** *

*/ public class GeometricObject { private String color; private boolean filled;

public GeometricObject() { this.color = "white"; this.filled = true; }

public GeometricObject(String color, boolean filled) { this.color = color; this.filled = filled; }

public String getColor() { return color; }

public void setColor(String color) { this.color = color; }

public boolean isFilled() { return filled; }

public void setFilled(boolean filled) { this.filled = filled; }

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions