Purpose

Purpose: Utilized Java abstract classes and interfaces for geometric objects.
Problem: Complete problem 15.13 (modified) on page 593 in Liang. Write a program (driver) to read in a series of values from a file, display the area and the perimeter, create a clone and compare the object and its clone (based on the area). In addition, your program should compare the current object (just read in) with the first object read in.
Input: Read the size (the value of the side - double) for each object (one per line) and carry out the computations. When a negative number is ***** end the program.
Output: Print out each object area and perimeter and the results of the comparisons. Sample output:
5.0 Object 1: Area: 120.71 Perimeter: 40.0
Clone compare: Equal
First compare: Equal
7.5 Object 2: Area: 271.60 (.599) Perimeter: 60.0
Clone compare: Equal
First compare: First is smaller
Data: Use the input file prog7.dat in the instructor account.
The Data from prog7.dat is....
5.0
7.5
3.26
0.0
-1.0

 

 
Powered by