Do the following using Swift Xcode project (using macOS and choosing option/tab: Command line Tool): Create a class CarLoan (store it in a separate file – CarLoan.swift) which is having the following: Loan number, customer name, yearly interest rate, loan amount and duration (time period) as stored properties Define private setter for loan number and customer name Loan amount should not be negative or zero Interest rate should be positive and between 1.0% and 4.0 %. Default – 1.0% Time duration cannot be negative and cannot be more than 7 years. Min – 3 years You need to define property observers – didSet for interest rate, loan amount and time duration. Down payment should be at least 10% of loan amount or more but it cannot be equal to loan amount. Define it as computed property.   Define two initializers, one which initializes all the properties to their default values and one which initializes to appropriate values. Define a Print as computed property which display all the instance data member’s values of loan object. This should be defined in the class extension file – CarLoanExtensions.swift.   And a convenience initializer which only initializes loan number and customer name and loan amount. It should be defined in the class extension file – CarLoanExtensions.swift Define one function- CalculateMonthlyInstallment() --> Double which is used for calculating the monthly installment  on the loan amount based on the rate and time. Use formula:  Interest = (loan amount – down payment) * rate * time / 100. Monthly Installments =  ((loan amount – down payment) + Interest)/ (time * 12)   Test the above class in main.swift file by creating at least two objects of CarLoan and test its capabilities.

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

Do the following using Swift Xcode project (using macOS and choosing option/tab: Command line Tool): Create a class CarLoan (store it in a separate file – CarLoan.swift) which is having the following:

Loan number, customer name, yearly interest rate, loan amount and duration (time period) as stored properties

Define private setter for loan number and customer name

Loan amount should not be negative or zero

Interest rate should be positive and between 1.0% and 4.0 %. Default – 1.0%

Time duration cannot be negative and cannot be more than 7 years. Min – 3 years

You need to define property observersdidSet for interest rate, loan amount and time duration.

Down payment should be at least 10% of loan amount or more but it cannot be equal to loan amount. Define it as computed property.

 

Define two initializers, one which initializes all the properties to their default values and one which initializes to appropriate values.

Define a Print as computed property which display all the instance data member’s values of loan object. This should be defined in the class extension file – CarLoanExtensions.swift.

 

And a convenience initializer which only initializes loan number and customer name and loan amount. It should be defined in the class extension file – CarLoanExtensions.swift

Define one function- CalculateMonthlyInstallment() --> Double which is used for calculating the monthly installment  on the loan amount based on the rate and time. Use formula:  Interest = (loan amount – down payment) * rate * time / 100. Monthly Installments =  ((loan amount – down payment) + Interest)/ (time * 12)  

Test the above class in main.swift file by creating at least two objects of CarLoan and test its capabilities.  

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar 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