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 Internet.) 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. Code I was given - public abstract class Element {     String symbol;     int atomicNumber;     double atomicWeight;     public Element(String s, int an, double aw)     {         // write your code here     }     public String getSymbol()     {         // write your code here     }     public int getAtomicNumber()     {         // write your code here     }     public double getAtomicWeight()     {         // write your code here     }     public abstract void describeElement(); } public class ElementArray {     public static void main(String[] args)     {         Element elements[] = new Element[5];         int i;         elements[0] = new MetalElement("Au", 79, 197.0);         elements[1] = new NonMetalElement("He", 2, 4.003);         elements[2] = new MetalElement("Ag", 47, 107.9);         elements[3] = new NonMetalElement("Ne", 1029, 20.18);         elements[4] = new MetalElement("Cu", 29, 63.55);         for(i = 0; i < elements.length; ++i)             elements[i].describeElement();     } } public class MetalElement extends Element {     public MetalElement(String s, int an, double aw)     {         // write your code here     }     public void describeElement()     {         // write your code here     } } public class NonMetalElement extends Element {     public NonMetalElement(String s, int an, double aw)     {         // write your code here     }     public void describeElement()     {         // write your code here     } }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

This is the question -

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 Internet.) 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.

Code I was given -
public abstract class Element
{
    String symbol;
    int atomicNumber;
    double atomicWeight;
    public Element(String s, int an, double aw)
    {
        // write your code here
    }
    public String getSymbol()
    {
        // write your code here
    }
    public int getAtomicNumber()
    {
        // write your code here
    }
    public double getAtomicWeight()
    {
        // write your code here
    }
    public abstract void describeElement();
}
public class ElementArray
{
    public static void main(String[] args)
    {
        Element elements[] = new Element[5];
        int i;
        elements[0] = new MetalElement("Au", 79, 197.0);
        elements[1] = new NonMetalElement("He", 2, 4.003);
        elements[2] = new MetalElement("Ag", 47, 107.9);
        elements[3] = new NonMetalElement("Ne", 1029, 20.18);
        elements[4] = new MetalElement("Cu", 29, 63.55);
        for(i = 0; i < elements.length; ++i)
            elements[i].describeElement();
    }
}
public class MetalElement extends Element
{
    public MetalElement(String s, int an, double aw)
    {
        // write your code here
    }
    public void describeElement()
    {
        // write your code here
    }
}
public class NonMetalElement extends Element
{
    public NonMetalElement(String s, int an, double aw)
    {
        // write your code here
    }
    public void describeElement()
    {
        // write your code here
    }
}
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 1 images

Blurred answer
Knowledge Booster
User Defined DataType
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education