Posts

Showing posts from December, 2020

Task 10a - Interfaces in Java - Java Programming Practice Exercise

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