Question: The program will skip erroneous lines in the file. After the instances are created and stored in an ArrayList, the program will allow user

The program will skip erroneous lines in the file. After the instancesare created and stored in an ArrayList, the program will allow userto perform the following operations repeatedly: 1 Search by length 2 Search

The program will skip erroneous lines in the file. After the instances are created and stored in an ArrayList, the program will allow user to perform the following operations repeatedly: 1 Search by length 2 Search by height 3 Quit Option 1 The program will prompt the user to enter a number (length) and display all instances with length >= the length entered by the user. The program will display an appropriate message if there is no matching instance. The program must handle incorrect data input: non-numeric input and invalid length (0 or negative). Option 2 The program will prompt the user to enter a number (height) and display all instances with height >= the height entered by the user. The program will display an appropriate message if there is no matching instance. The program must handle incorrect data input: non-numeric input and invalid height (0 or negative). Program Structure You may include additional classes as you deem fit. public class Question 3 { public static void main(String[] argv) { // Your code ... } } class Rectangle { // Your code } class Cuboid ... { // Your code } class Pyramid ... ( // Your code ... } Question 3 Write a Java program to allow user to create instances of Rectangle, Cuboid and Pyramid; and search the instances by different criteria. The details of the classes are given as follows: class Instance variables Constructor Get and set methods getArea toString Rectangle Length and width of a rectangle. You may decide the type of each instance variable. You may include additional variables as you deem fit. A non default constructor that receives parameters and initialises the instance variables. Include get and set methods for all instance variables. Instance method to calculate and return the rectangle's area, which is length x width. Return a descriptive String of the instance. class Instance variables Constructor Get and set methods getArea getVolume toString Cuboid (subclass of Rectangle) Height of a cuboid. You may decide the type of each instance variable. You may include additional variables as you deem fit. A non default constructor that receives parameters and initialises the instance variables, including the instance variables of the base class. Include get and set methods for all instance variables. Instance method to calculate and return the surface area (6 sides) of a cuboid. Instance method to calculate and return the volume of a cuboid, which is base area x height. Return a descriptive String of the instance. class Instance variables Constructor Get and set methods getVolume toString Pyramid (subclass of Rectangle) Height of a pyramid. You may decide the type of each instance variable. You may include additional variables as you deem fit. A non default constructor that receives parameters and initialises the instance variables, including the instance variables of the base class. Include get and set methods for all instance variables. Instance method to calculate and return the volume of a pyramid, which is (base area x height) / 3. Return a descriptive String of the instance. Note: The Pyramid class does not override the getArea method. The program must read a text file containing the instance data, create an appropriate instance (Rectangle, Cuboid or Pyramid) for each data, and store it in an ArrayList for subsequent use. A sample of the text file is shown below. C, 10.5, 20.5,30 P, 5, 10, 15.3 R, 2,5.5 P,2,5,10 C,5,A,20 P, 0,10,-1 C,8,10,15 You may assume the following regarding the values in the text file: There can be any number of lines in the text file. The first value is either R (rectangle), C (cuboid) or P (pyramid). Rectangle will have 2 values: length and width after R. Cuboid will have 3 values: length, width and height after C. Pyramid will have 3 values: length, width and height after P. Length, width and height may contain invalid values: 0, negative or non-numeric.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The below is the JAVA code for the above problem import javaioFile import javaioFileNotFoundException import javautilArrayList import javautilScanner Rectangel class class Rectangle private double len... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!