Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

post answer with screen shot of code because it makes the indentations easier to understand Java Interfaces An interface is a refercnce type in lava.

post answer with screen shot of code because it makes the indentations easier to understand
image text in transcribed
Java Interfaces An interface is a refercnce type in lava. It is similar to a class. It is a collective of abstract methods. A class implements an interface, thereby inberitine the abstract methods of the interface. Alone with abetract methods, an interface may also coetain constants, default methods. static methods, and nested types. Method bodies exist only for default methods and static methods. Camplefe the two programming questioess below Questien -i (CarbonFeotprint Interface: Folymorphism) Using imanfices, you can specify simalar behaviors fer possibly disparate classes. Govenancms and companies worldwide are becoming increasingly eonccmed with carbon footprints aanual releases of carbee dioxide into the atesosphere) from buildings buraing various types of fuels foe heat, vehicles burning fucls for power, and the like. Many scientists blame this greenhouse gases for the phenomenon called global warming. Create three small classes unrelated by inhentance - classes Bualding. Car, and Bicycle. Give sach class some uniqges appeopeiate attributes and behaviors that in does not have in conmon with other classes. Write an interface CarbonF ootprint with a pctCarbonfiootprint method. Ilave cach of your classes implement that interface, so that its getCarbenfootgeint methed caleulates an appropriate carbon footpeint for that class (check out a few websitcs that ceplain how to calculate carbon footprints). Write an application that creates objects of each of the three classes, places references to those objects in ArrayLast Carbonfwotprints, then iterates through the ArayList, polymorphically invoking each object's getCarbonfootpriat methed. For each object, print weene identifying information and the object's carbee footprint. Queation al (Construction Loaa Compaay Interface: Polymerphism) HighTech Construction Loan Company makes loans of up to $500,000 for construction projects. There are two catcyories of Loans - those to businesses and these to indrvidual applicants. Write an application that tracks all ncw construction louns. The application mus also cakulate the total anount owed at the due dafe (original loae amount + loan fee). The application stoculd inclade the followiege classes: Laan-A public absiract class that implements the LoanConstants interface. A Loan includes a loan number, cusslotmer's last name, amouns of kap, inserest fate, and ierm. The constructor requires data for each of the fields except interest rate. Do not allow loan amounts over $00,000. Force any loan term that is nee one of the threc defined in the LoanCotstants class lo a short-term, 1-year loan. Create a toStringe) method that desplays all the loan data. LoanConstants - A public interface class. LoanConstants inchades constant values for short-term (1 year), medium-term ( 3 years), and loeg-term ( 5 years) loans. It also contains coostants for the company name and the maximum losen amount. BusinessLoan - A public class that exbends Loan. The BusinessLoan constructor sets the interest rate to I percent over the current prime interest rate. Personalloan-A public class that extends Loan. The Personalloan coentructor sets the interest rate to 2 percent over the current prime interest rate. CreaeLoans-At applicative that creates an array of five Loans. Prompe the user for the current prime interest rate. Then, in a loop, peompt the user for a loan type and alf relevant information for that kan. Soere the created Loan objects in the array. When data eatry is complete, display all the loans. Save the files as L.ean.java, LeanCenstaers.java, Hasioesilean.java, Personall ean.java, and Createl_aabk.java

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

4. Keep feelings hidden, reserved, unexpressed?

Answered: 1 week ago