1 INSY 4305 ADVANCED APPLICATION DEVELOPMENT ASSINGMENT 5 20 points 1. INSTRUCTIONS • For the late submissions, 2% of the total points will be deducted per hour automatically on Canvas. • PLEASE, ONLY...

1 answer below »
there are 2 questions


1 INSY 4305 ADVANCED APPLICATION DEVELOPMENT ASSINGMENT 5 20 points 1. INSTRUCTIONS • For the late submissions, 2% of the total points will be deducted per hour automatically on Canvas. • PLEASE, ONLY USE TECHNIQUES THAT WE LEARNED IN CHAPTER 10 AND CHAPTER 14. • If you use other techniques, 4 pts will be deducted. • In this assignment, you are expected to upload one .zip/.rar file including five Java applications. o YourFirstNameLastName.zip/.rar [including Shape.java, Rectangle.java, Triangle.java, ShapeTest.java, Comparison.java] • Each question is independent of each other. • Do not forget to add comments to explain how your codes are working! Short comments are acceptable. • Write your codes individually! Do not copy of any of them from someone else! • NOTE: If you are using any IDE (Netbeans, Eclipse, etc.), please delete the statement package xxxxx; (and save it again), from your application. Otherwise, I will get a compilation error, and you will lose 1 pt for each file giving a compilation error. It is your responsibility. 2 2. GRADING POLICY • Case 1: o For each question: o I will compile your .java files. If any compilation error occurs, 1 pt will be deducted from each file including a compilation error. o After that, I will check your algorithms whether they are correct or not. For example; if it says find odd and even numbers. I will check whether it really finds both even and odd numbers. This part will be evaluated based on your work. o Additionally, comments will be checked whether they clearly and briefly explain what you have done. If comments are missing or not clear, enough, or brief 1 pt will be deducted. • Case 2: o For each question: o If there is not any compilation error: ▪ I will try each case scenario stated in each question. For example; if it says find odd and even numbers. I will try both even and odd numbers. This part will be evaluated based on your work. ▪ Additionally, comments will be checked whether they clearly and briefly explain what you have done. If comments are missing or not clear, enough, or brief 1 pt will be deducted. • Case 3: o If you do not upload a .java file, I will not evaluate your answer. • Case 4: o If it is determined that you copy the codes from someone else, you will get 0 pt. 3 QUESTIONS 1. (12 pts) Implement hierarchy shown below. • Shape is an abstract class including two private instance variables: height and width, a constructor, set and get methods (height and width must be greater than 0, otherwise throw IllegalArgumentException), toString method, and an abstract method called getArea. • The class rectangle has one private instance variable: color, a constructor, set and get, toString, and getArea (height*width) methods. • The class Triangle has one private instance variable: classification (for example; equilateral), a constructor, set and get, toString, and getArea (height*width/2) methods. • Create a test file named ShapeTest. Create one object from the classes Rectangle and Triangle. Then, create an array of Shape references to objects of each subclass in the hierarchy. • Then, create an enhanced for loop that processes all the shapes in the array. If the object belongs to class Triangle, display a message that the object is a Triangle. If the object belongs to class Rectangle, display a message that the object is a Rectangle. • UPLOAD Shape.java Rectange.java Triangle.java ShapeTest.java 2. (8 pts) Write an application that reads two inputs. Then, use the method regionMatches to compare these two String inputs. Ask for the number of characters to be compared and the starting index of the comparison. Display whether the compared characters are equal or not. Perform the comparison by ignoring the case of the characters. UPLOAD Comparison.java Shape Rectangle Triangle 4
Answered Same DayApr 28, 2021

Answer To: 1 INSY 4305 ADVANCED APPLICATION DEVELOPMENT ASSINGMENT 5 20 points 1. INSTRUCTIONS • For the late...

Ankit answered on May 01 2021
139 Votes
Assignment_5/Comparison.java
Assignment_5/Comparison.java
import java.util.Scanner;
// Program to use the method regionMatches to compare two u
ser String inputs
public class Comparison {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String s1, s2;
        int no_of_characters,starting_index;
        Scanner in = new Scanner(System.in);
        System.out.println("Please enter first string:");
        s1 = in.nextLine();
        System.out.println("Please enter second string:");
        s2 = in.nextLine();
        System.out.println("Please enter number of characters:");
        no_of_characters = in.nextInt();
        System.out.println("Please enter starting index:");
        starting_index = in.nextInt();

//      Performing the comparison by ignoring the case of the characters

        boolean results = s1.regionMatches(true,starting_index, s2, starting_index, no_of_characters);
        if (results)
            System.out.println("The strings are equal");
        else
            System.out.println("The strings are not equal");
        in.close();
    }
}
Assignment_5/Rectangle.java
Assignment_5/Rectangle.java
//Java file for defining color, width and height of Rectangle
public class Rectangle extends Shape{

    private String color;
    public Rectangle(double height,double width,String color) {
        super(height, widt...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here