
In Java.
Define the class InvalidSideException, which inherits from the Exception class. Also define a Square class, which has one method variable -- an int describing the side length. The constructor of the Square class should take one argument, an int meant to initialize the side length; however, if the argument is not greater than 0, the constructor should throw an InvalidSideError. The Square class should also have a method getArea(), which returns the area of the square.
Create a Driver class with a main method to test your classes. Your
The words for output is highlighted in grey and yellow in the blue box. Class should be named Driver, as shown in blue box as well.


Step by stepSolved in 3 steps with 1 images

Could you please add some comments in the code?
Could you please add some comments in the code?
- In Java Attachedarrow_forwardDefine a class named “A” manages a document id (integer)and a document title (string).This class will throw the InvalidItemException whenever a A is created with a negative ID or an empty or blank title with proper error code.The class must at least provide the following methods: isDuplicatemethodthat compares with another A or its derived class object. It returns true if both have the same ID and title and false otherwise. isAlphabeticallyBeforemethod that compares with another A derived class object. It returns true if its title is alphabetically before the otherA’s title and false otherwisearrow_forwardPlease write the Java program for the given scenario Create a CourseException class that extends Exception . Create a Course class with String that holds a college course’s department (for example, CSE), a course number (for example, 101), and a number of credits (for example, 3) and whose getdata() member function requires values for each field., throw a CourseException if the department does not consist of three letters, if the course number does not consist of three digits between 100 and 499 inclusive, or if the credits are less than 0.5 or more than 6. Write an application and display an appropriate message when a Course object is created.arrow_forward
- Working With Java Classes Define a Java class as described below. All variables should be declared as private and all methods as public. Save the class definition in a file with an appropriate filename. Class Name: Family Instance Variables: numDependents - int (Fields) annualIncome - double Instance Methods: A constructor that accepts no arguments and sets the number of dependents field to 1 and the annual income field to zero. rate). A constructor that accepts 1 argument, an annual income amount and sets the number of dependents to1. A constructor that accept 2 arguments representing an initial value for each of the fields. Accessor/Getter Methods: (Use appropriate method names) dependents() A function to return the number of dependents. income() A function to return the annual income amount. Mutator/Setter Methods: (Use appropriate method names) dependents() A function that has an integer formal argument that is assigned to the number of dependents field. income() A function that…arrow_forwardFor JAVAarrow_forwardC++ Programming. Create a "Stool' class. Fields: height (h, cm), product quality (low, medium, high). Specify two virtual methods: The "Wood amount" method determines the amount of wood that goes into the stool: 4 • h + 12 if the product quality is low, 5 • h + 14 if the quality is average or high. "Price" method is equal to d • 2 for low quality, d • 3 for medium quality, d • 4 for high quality, where d is the amount of wood required for the object. Also write an "Information" method that prints information about the object: Height, Material Quality, Wood Quantity, and Price. Also create an inheritance class "Chair". Additional area: back height (h2, cm). In the reloaded "Amount of Wood" method, the amount of wood is calculated using the formula d + 2 • h2 + 5.arrow_forward
- JAVA Design a class named MyInteger. The class contains: An int data field named value that stores the int value represented by this object. A constructor that creates a MyInteger object for the specified int A get method that returns the int Methods isEven(), isOdd(), and isPrime() that return true if the value is even, odd, or prime, respectively. Static methods isEven(int), isOdd(int), and isPrime(int) that return true if the specified value is even, odd, or prime, respectively. Method equals(int) that return true if the value in the object is equal to the specified value.arrow_forwardPythonarrow_forwardIn Java: Define a class called Exam that manages a set of up to25 Question objects. Define the add method of the mainExam class to add a question to the exam. Define theassignExam method of the Exam class to present eachquestion in turn to the user, accept an answer for each one, and keeptrack of the results. Define a class called ExamTime witha main method that populates the exam, presents it, and prints thefinal results.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





