$30
CSC 471/371 Mobile Application Development for iOS
Programming Assignment 3: A Simple Calculator
Due Date & Submission
• Submit your assignment in D2L Dropbox.
• Submit a single zip file that contains the contents of the project folder
o To zip your project folder: Ctrl-click your project folder and select
“Compress …” from the context menu.
• It is mandatory to use Xcode 10 and Swift 4 for this assignment.
• Include only your source code files, including
o *.swift, *.plist, *.xib, *.storyboard
o image files
o project files (.xcodeproj)
o test folders
• You must use a unique prefix for the project name. (I suggest you use your last name
and first initial as your prefix.) Please use the same prefix for all your
assignments.
o Note you only need to use the prefix for the project name. It is not necessary
to use the prefix on other files in your project.
• Do not include unused or unrelated files.
• Before you submit, build and run the project, make sure everything compiles and
works. Close your project before zipping the folder.
• Here are the most common reasons assignments are marked down:
o Project does not build.
o Project does not build without warnings.
o One or more items in the Requirements section were not satisfied.
o A fundamental concept was not understood.
o Code is sloppy and hard to read (e.g. indentation is not consistent, etc.).
o Your solution is difficult (or impossible) for someone reading the code to
understand due to lack of comments, poor variable/method names, poor
solution structure, etc.
• Bonus points.
o Bonus points may be awarded to projects with exceptional qualities in one or
more aspects.
o Bonus points will only be awarded after all the required elements have been
satisfied.
o Bonus points will not be awarded merely for extra amount of work (or code).
o Extra and sloppy code may cause your assignments to be marked down.
o Bonus points are awarded at the sole discretion of the instructor.
Goals
• Explore Xcode and Swift language
• Explore Swift andiOS API documentation
o String class
o UIButton and UILabel classes
• Connect outlets and actions in Xcode
Assignments
1. Create a simple calculator app similar to the one shown below
o Use UIButton for the digits, ‘+’, and ‘=’ keys.
o Use a UILabel to display the result.
o You only need to handle integer additions in this assignment.
o The current number should be displayed after each digit key is pressed.
o After the ‘+’ key is pressed, the app waits for the next number to be added.
o The result, i.e., the sum, should be displayed after the ‘=’ key is pressed.
o Your app should properly handle key stroke sequences such as follows:
o 1 2 + 4 5 =
o 1 2 + 4 5 = + 6 7 =
2. Make sure your program
a. builds without errors or warnings, and
b. runs without crashing
Hints
The following are some of the methods and properties that might be useful in this
assignment.
• Use Int(str) to convert a string to an integer. (Note that the result type is an
optional type.)
Look them up in the API documentation for how to use these and other methods and
properties.
• UILable class reference
o text property
• UIButton class reference
o currentTitle property