First SwiftUI Assignment

Make a simple loan calculator. Your app will consist of a single view.

The calculator will compute the monthly payment for a loan given the loan amount, the term of the loan in years, and the annual percentage rate on the loan.

To compute the monthly payment use the formula

where rate is the APR divided by 1200 and n is the term in years times 12. To compute an exponent in Swift, use the pow() function:

ab = pow(a,b)

Helpful hints

To make your user interface look better, here are some suggestions.

1) Apply the modifier .frame(width:110,height:20,alignment: .trailing) to the text labels that sit in front of the text fields. This will ensure that all of the labels have the same width, which in turn will ensure that the text fields to the right of the labels look nice.

2) Apply the modifier .textFieldStyle(.roundedBorder) to the text fields. The default text field style in SwiftUI does not have a border, so it helpful to add one.

3) Apply the modifier .buttonStyle(.bordered) to the button. This will make the button look a little more like a button.