Page 1 of 2 COP 3337: Computer Programming II Assignment – V Due Date & Time: Sunday Dec 5, XXXXXXXXXX:59 pm Instructor: Ahmad Waqas Instructions: ➢ Create a separate java project for each task. ➢ Put...

1 answer below »
Define a interface name shape with a single method name area that calculates the area of the geometric shape:



Page 1 of 2 COP 3337: Computer Programming II Assignment – V Due Date & Time: Sunday Dec 5, 2021 11:59 pm Instructor: Ahmad Waqas Instructions: ➢ Create a separate java project for each task. ➢ Put all the projects in one folder (folder name must be your name) and create the .zip file for submission. ➢ All tasks carry equal marks. i.e., 5 ➢ The general rubrics are given below: Description Max. Marks Coding style Use the best practices for writing the code. The code is well organized and very easy to follow. 20% Logic Student has used the effective programming logic for solution and demonstrates the appropriate concept (binding, abstract methods, exceptions, and files) in respective task. 60% Results The program is error-free and generates the expected results as per the specifications. 20% Task – I: Define an interface named Shape with a single method named area that calculates the area of the geometric shape: public double area(); Next, define a class named Circle that implements Shape. The Circle class should have an instance variable for the radius, a constructor that sets the radius, accessor/mutator methods for the radius, and an implementation of the area method. Also define a class named Rectangle that implements Shape. The Rectangle class should have instance variables for the height and width, a constructor that sets the height and width, accessor and mutator methods for the height and width, and an implementation of the area method. The following test code should then output the area of the Circle and Rectangle objects: public static void main(String[] args){ Circle c = new Circle(4); // Radius of 4 Rectangle r = new Rectangle(4,3); // Height = 4, Width = 3 ShowArea(c); ShowArea(r); } public static void ShowArea(Shape s){ double area = s.area(); System.out.println("The area of the shape is " + area); } Page 2 of 2 Task – II: Given an expression string, write a program to examine whether the pairs and the orders of parenthesis {, }, (, ), [, ] are correct in expression. For example, if the input: expression is entered by user is [()]{}{[()()]()},then the output should print “Balanced”. If the input: expression entered by user is [(]), then the output is “Not Balanced” Hint: Traverse the input string and use stack to push if you encounter an opening parenthesis and pop if you encounter a closing parenthesis of the same type.
Answered Same DayDec 05, 2021

Answer To: Page 1 of 2 COP 3337: Computer Programming II Assignment – V Due Date & Time: Sunday Dec 5,...

Arun Shankar answered on Dec 06 2021
116 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here