JAVA ASSIGNMENT- please find the pdf in the attached file
Assignments: 1. Write a program that calculates the area of a circle? 2. Write a program that uses looping to print the following pattern? * * * * * * * * * * * * * * * * * * * * * 3. Write a program to check if A string is a palindrome. 4. Write a function that returns the nth odd number in an array of integers, as below: public class NumberUtil { public static int getNthOddNumber(int[] inputArray, int n) { // TODO: implement the body using any of the java loops return 0; } public static void main(String[] args) { int[] intArray = { 2, 4, 1, 55, 2, 33, 41, 20}; int n = 3; System.out.println(“The ” + n + “th odd number in the array is: ” + getNthOddNumber(intArray, n)); } } The output should be 33 in the above case. Return -1 if there is no nth odd number. (Ignore grammar in the output :-)) 5. Write an abstract class Book with a field for the title, an abstract method to set the title and a method to get the title. Write a subclass TextBook which implements the abstract method in the Book class. Write a main class that instantiates TextBook, sets the title and prints the title of the TextBook using the getter. 6. Write program that uses try/catch to catch ArithmeticException when 2 integers are divided – (eg: 2/0) 7. Write a program to test if 2 strings are Anagrams 8. Write a Circle class with attribute radius. It should have a no- args constructor, constructor that takes a radius input, getter and setter methods for the radius. Write a subclass of Circle: Cylinder which has an additional attribute height. It has its own set of getter and setter methods for the height.
