Part 1: Create an abstract class named Element that holds properties of elements, including their symbol, atomic number, and atomic weight. Include a constructor that requires values for all three properties and a get method for each value. (For example, the symbol for carbon is C, its atomic number is 6, and its atomic weight is 12.01. You can find these values by reading a periodic table in a chemistry reference or by searching the Web.) Also include an abstract method named describeElement(). Create two extended classes named MetalElement and NonMetalElement. Each contains a describeElement() method that displays the details of the element and a brief explanation of the properties of the element type. For example, metals are good conductors of electricity, while nonmetals are poor conductors.Write an application named ElementArray that creates and displays an array that holds at least two elements of each type. Save the files as Element.java, MetalElement.java, NonMetalElement.java, and ElementArray.java.
Part2: Create a class named NewspaperSubscriber with fields for a subscriber's street
address and the subscription rate. Include get and set methods for the subscriber's
street address, and include get and set methods for the subscription rate. The set
method for the rate is abstract. Include an equals() method that indicates two
Subscribers are equal if they have the same street address. Create child classes
named SevenDaySubscriber, WeekdaySubscriber, and WeekendSubscriber. Each
child class constructor sets the rate as follows: SevenDaySubscribers pay $4.50 per
week, WeekdaySubscribers pay $3.50 per week, and WeekendSubscribers pay
$2.00 per week. Each child class should include a toString() method that returns
the street address, rate, and service type. Write an application named Subscribers
that prompts the user for the subscriber's street address and requested service, and
then creates the appropriate object based on the service type. Do not let the user
enter more than one subscription type for any given street address. Save the files as
NewspaperSubscriber.java, WeekdaySubscriber.java, WeekendSubscriber.
java, SevenDaySubscriber.java, and Subscribers.java.
Part3:Picky Publishing House publishes stories in three categories and has strict requirements
for page counts in each category. Create an abstract class named Story that
includes a story title, an author name, a number of pages, and a String message.
Include get and set methods for each field. The method that sets the number of pages
is abstract. Also include constants for the page limits in each category. Create three
Story subclasses named Novel, Novella, and ShortStory, each with a unique
setPages() method. A Novel must have more than 100 pages, a Novella must have
between 50 and 100 pages inclusive, and a ShortStory must have fewer than
50 pages. If the parameter passed to any of the set methods in the child class is out of
range, set the page value but also create and store a message that indicates how many
pages must be added or cut to satisfy the rules for the story type. Write an application
named StoryDemo that creates an array of at least six objects to demonstrate how
the methods work for objects created both with valid and invalid page counts for
each story type. For each story, display the title, author, page count, and message
if any was generated. Figure 11-34 shows a sample execution. Save the files as
Story.java, Novel.java, Novella.java, ShortStory.java, and StoryDemo.java.
Part4:Write an application named UseInsurance that uses an abstract Insurance class
and Health and Life subclasses to display different types of insurance policies
and the cost per month. The Insurance class contains a String representing the
type of insurance and a double that holds the monthly price. The Insurance class
constructor requires a String argument indicating the type of insurance, but the
Life and Health class constructors require no arguments. The Insurance class
contains a get method for each field; it also contains two abstract methods named
setCost() and display(). The Life class setCost() method sets the monthly fee
to $36, and the Health class sets the monthly fee to $196. Write an application
named UseInsurance that prompts the user for the type of insurance to bedisplayed, and then create the appropriate object. Save the files as Life.java,
Health.java, Insurance.java, and UseInsurance.java.