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.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 1CP: In previous chapters, you have created programs for the Greenville Idol competition. Now create a...
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT