JAVA CODE: class quad{ public static void main(String args[] ){ Quadrilateral quadrilateral = new Quadrilateral( 1.1, 1.2, 6.6, 2.8, 6.2, 9.9, 2.2, 7.4 ); Trapezoid trapezoid = new Trapezoid (0.0, 0.0, 10.0, 0.0, 8.0, 5.0, 3.3, 5.0 ); Parallelogram parallelogram = new Parallelogram (5.0, 5.0, 11.0, 5.0, 12.0, 20.0, 6.0, 20.0 ); Rectagle rectagle = new Rectagle(17.0, 14.0, 30.0, 14.0, 30.0, 28.0, 17.0, 28.0 ); Square square = new Square( 4.0, 0.0, 8.0, 0.0, 8.0, 4.0, 4.0, 4.0 ); System.out.printf("%s %s %s %s %s\n", quadrilateral, trapezoid, parallelogram, rectagle, square ); } } class Point{ private double x; private double y; public Point(double xCoordinate, double yCoordinate){ x = xCoordinate; y = yCoordinate; } public double getX(){ return x; } public double getY(){ return y; } public String toString(){ return String.format( "( %.1f, %.1f)", getX(), getY() ); } } class Quadrilateral { private Point point1; private Point point2; private Point point3; private Point point4; public Quadrilateral( double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4){ point1 = new Point( x1, y1 ); point2 = new Point( x2, y2 ); point3 = new Point( x3, y3 ); point4 = new Point( x4, y4 ); } public Point getPoint1(){ return point1; } public Point getPoint2(){ return point2; } public Point getPoint3(){ return point3; } public Point getPoint4(){ return point4; } public String toString(){ return String.format( "%s:\n%s","COORDINATES OF QUADRILATERAL ARE: ", getCoordinatesAsString() ); } public String getCoordinatesAsString(){ return String.format("%s,%s,%s,%s,%s\n", point1, point2, point3,point4 ); } } class Trapezoid extends Quadrilateral { private double height; public Trapezoid(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4){ super(x1, y1, x2, y2, x3, y3, x4, y4); } public double getHeight(){ if (getPoint1().getY() == getPoint2().getY() ) return Math.abs( getPoint2().getY() - getPoint3().getY() ); else return Math.abs( getPoint1().getY() - getPoint2().getY() ); } public double getArea(){ return getSumOfTwoSides() * getHeight() / 2.0; } public double getSumOfTwoSides(){ if (getPoint1().getY() == getPoint2().getY() ) return Math.abs( getPoint1().getX() - getPoint2().getX() ) + Math.abs( getPoint3().getX() - getPoint4().getX() ); else return Math.abs( getPoint2().getX() - getPoint3().getX() )+ Math.abs( getPoint4().getX() - getPoint1().getX() ); } public String toString() { return String.format("\n%s:\n%s: %s\n%s: %s\n", "COORDINATES OF TRAPEZOID ARE", getCoordinatesAsString(), "Height is:", getHeight(), "Area is:", getArea() ); } class Parallelogram extends Trapezoid{ public Parallelogram( double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4 ){ super ( x1, y1, x2, y2, x3, y3, x4, y4); } public double getWidth(){ if (getPoint1().getY() == getPoint2().getY() ) return Math.abs( getPoint1().getX() - getPoint2().getX() ); else return Math.abs( getPoint2().getX() - getPoint3().getX() ); } public String toString(){ return String.format( "\n%s:\n%s%s: %s\n%s: %s\n%s: %s\n","COORDINATES OF PARALELLOGRAM ARE:",getCoordinatesAsString(), "Width is", getWidth(),"Height is", getHeight(),"Area is:", getArea() ); } } class Rectagle extends Parallelogram{ public Rectagle( double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4 ){ super ( x1, y1, x2, y2, x3, y3, x4, y4); } public String toString(){ return String.format( "\n%s:\n%s%s: %s\n%s: %s\n%s: %s\n","COORDINATES OF RECTAGLE ARE:",getCoordinatesAsString(), "Width is", getWidth(),"Height is", getHeight(),"Area is:", getArea()); } class Square extends Parallelogram{ public Square( double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4 ){ super ( x1, y1, x2, y2, x3, y3, x4, y4); } public String toString(){ return String.format( "\n%s:\n%s%s: %s\n%s: %s\n%s: %s\n","COORDINATES OF SQUARE ARE:",getCoordinatesAsString(), "Width is", getWidth(),"Height is", getHeight(),"Area is:", getArea() ); } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

HELLO! PLEASE HELP ME FIX THE ERROR THANKYOU. :)

 

JAVA CODE:

class quad{
public static void main(String args[] ){

Quadrilateral quadrilateral = new Quadrilateral( 1.1, 1.2, 6.6, 2.8, 6.2, 9.9, 2.2, 7.4 );

Trapezoid trapezoid = new Trapezoid (0.0, 0.0, 10.0, 0.0, 8.0, 5.0, 3.3, 5.0 );

Parallelogram parallelogram = new Parallelogram (5.0, 5.0, 11.0, 5.0, 12.0, 20.0, 6.0, 20.0 );

Rectagle rectagle = new Rectagle(17.0, 14.0, 30.0, 14.0, 30.0, 28.0, 17.0, 28.0 );

Square square = new Square( 4.0, 0.0, 8.0, 0.0, 8.0, 4.0, 4.0, 4.0 );

System.out.printf("%s %s %s %s %s\n", quadrilateral, trapezoid, parallelogram, rectagle, square );
}
}
class Point{
private double x;
private double y;

public Point(double xCoordinate, double yCoordinate){
x = xCoordinate;
y = yCoordinate;
}
public double getX(){
return x;
}
public double getY(){
return y;
}
public String toString(){
return String.format( "( %.1f, %.1f)", getX(), getY() );
}
}
class Quadrilateral {
private Point point1;
private Point point2;
private Point point3;
private Point point4;

public Quadrilateral( double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4){
point1 = new Point( x1, y1 );
point2 = new Point( x2, y2 );
point3 = new Point( x3, y3 );
point4 = new Point( x4, y4 );
}
public Point getPoint1(){
return point1;
}
public Point getPoint2(){
return point2;
}
public Point getPoint3(){
return point3;
}
public Point getPoint4(){
return point4;
}
public String toString(){
return String.format( "%s:\n%s","COORDINATES OF QUADRILATERAL ARE: ", getCoordinatesAsString() );
}
public String getCoordinatesAsString(){
return String.format("%s,%s,%s,%s,%s\n", point1, point2, point3,point4 );
}
}
class Trapezoid extends Quadrilateral {
private double height;
public Trapezoid(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4){
super(x1, y1, x2, y2, x3, y3, x4, y4);
}
public double getHeight(){
if (getPoint1().getY() == getPoint2().getY() )
return Math.abs( getPoint2().getY() - getPoint3().getY() );
else
return Math.abs( getPoint1().getY() - getPoint2().getY() );
}
public double getArea(){
return getSumOfTwoSides() * getHeight() / 2.0;
}
public double getSumOfTwoSides(){
if (getPoint1().getY() == getPoint2().getY() )
return Math.abs( getPoint1().getX() - getPoint2().getX() ) +
Math.abs( getPoint3().getX() - getPoint4().getX() );
else
return Math.abs( getPoint2().getX() - getPoint3().getX() )+
Math.abs( getPoint4().getX() - getPoint1().getX() );
}
public String toString() {
return String.format("\n%s:\n%s: %s\n%s: %s\n", "COORDINATES OF TRAPEZOID ARE", getCoordinatesAsString(), "Height is:", getHeight(), "Area is:", getArea() );
}
class Parallelogram extends Trapezoid{
public Parallelogram( double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4 ){
super ( x1, y1, x2, y2, x3, y3, x4, y4);
}
public double getWidth(){
if (getPoint1().getY() == getPoint2().getY() )
return Math.abs( getPoint1().getX() - getPoint2().getX() );
else
return Math.abs( getPoint2().getX() - getPoint3().getX() );
}
public String toString(){
return String.format( "\n%s:\n%s%s: %s\n%s: %s\n%s: %s\n","COORDINATES OF PARALELLOGRAM ARE:",getCoordinatesAsString(), "Width is", getWidth(),"Height is", getHeight(),"Area is:", getArea() );
}
}
class Rectagle extends Parallelogram{
public Rectagle( double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4 ){
super ( x1, y1, x2, y2, x3, y3, x4, y4);
}
public String toString(){
return String.format( "\n%s:\n%s%s: %s\n%s: %s\n%s: %s\n","COORDINATES OF RECTAGLE ARE:",getCoordinatesAsString(), "Width is", getWidth(),"Height is", getHeight(),"Area is:", getArea());
}
class Square extends Parallelogram{
public Square( double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4 ){
super ( x1, y1, x2, y2, x3, y3, x4, y4);
}
public String toString(){
return String.format( "\n%s:\n%s%s: %s\n%s: %s\n%s: %s\n","COORDINATES OF SQUARE ARE:",getCoordinatesAsString(), "Width is", getWidth(),"Height is", getHeight(),"Area is:", getArea() );
}
}

ERROR:
Compilation
Point.java:103:
}
error: reached end of file while parsing
1 error
Not compiled
Transcribed Image Text:ERROR: Compilation Point.java:103: } error: reached end of file while parsing 1 error Not compiled
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education