Assignment 3 Statement
Assignment 3 Statement
Question 1:
Apply the concepts of Arrays and write down the Code.
Learning Outcome: CLO2-->SO3-->C3 (Apply)
Due to ever increasing use of fossil fuels (petrol, diesel, etc.) in our daily lives, the amount of
greenhouse gases i.e. Carbon Dioxide (CO2) in the atmosphere is rapidly increasing, which is
causing global warming. Scientists have associated values called “Carbon Footprint” to almost
all human activities. For example each square feet of a covered area generates about 0.005 tons
of CO2 annually. A car generates 0.0000292 tons of CO2 for each mile it is driven.
In order to handle the “Carbon Footprint”, your job is to create an interface called
CarbonFootPrintProducer that shall contain a method declaration called getCarbonFootPrint(),
that shall return a double value indicating the amount of CO2 generated by an instance of the
implementing class.
Your next job is to create two classes i.e. House and Car, both shall implement
CarbonFootPrintProducer interface. House must have an attribute coveredArea, while Car
must have an attribute milesDriven, both public. Create fully parametrized constructor in each
subclass. Both subclasses must contain their own getCarbonFootPrint() implementation that
shall calculate the CO2. For the calculation of CO2, use the following formulas.