CS 329E Assignment 1


Assignment 1: Introduction to Swift



Project Description

You are to familiarize yourself with the Swift language and the Xcode IDE by working in Playground. You will create a program in Swift to decide where to eat out based on your dining budget.

Basic Requirements

This budget planner will run for the 14 weeks of this semester. You have a weekly budget of $50 plus any left over dining money from the previous week that rolls over.

At the beginning of the week, you will print out "Week [week number]"

For every day in the week, you will 1) choose a random restaurant from a predetermined list, 2) calculate tax and tip for the given cost of a meal, and 3) determine if eating there is within your budget. If it is not, you will choose a different restuarant and see if that one meets your budget constraints. If it is, you will take the cost of dining there out of your current budget, and print the following line to the Playground's console:
"[day of the week] meal: [restaurant], budget now [current budget]"

The final output should look something like this:

Week 9
Sunday meal: Home, budget now 53.33
Monday meal: Madam Mam's, budget now 35.67
Tuesday meal: Kerby Lane, budget now 21.80
Wednesday meal: Teji's, budget now 10.72
Thursday meal: Home, budget now 10.72
Friday meal: Home, budget now 10.72
Saturday meal: Home, budget now 10.72

Week 10
Sunday meal: Milto's, budget now 47.46
Monday meal: Madam Mam's, budget now 29.80
Tuesday meal: Home, budget now 29.80
Wednesday meal: Teji's, budget now 18.72
Thursday meal: Verts, budget now 8.87
Friday meal: Home, budget now 8.87
Saturday meal: Home, budget now 8.87

The displayed budget should be formatted to show two decimal places. You can use the arc4random_uniform() that takes an unsigned integer and returns a random unsigned integer within that range to choose a random restaurant.

Getting Started

In order to complete this assignment, you must download Xcode 10 (or 11 if you'd like to use the beta) from the Mac Store (it is free). You will need an Apple ID if you don't already have one.

To create your assignment file, open Xcode and select New -> Playground. Name the playground file yourid_assignment1.playground.

The list of restaurant cost and tip is as follows:
Salty Sow: $30.00, 20%,
Kerby Lane: $10.99, 18%
Milto's: $10.50, 18%
Trudy's: $11.70, 18%
Madam Mam's: 13.99, 18%
Vert's: $7.99, 15%
Teji's: $8.99, 15%
Home: $0, 0%

Tax in Texas is 8.25%. You will calculate both tax and tip based on the original restaurant price then add these values to the total cost of the meal.

What to turn in

You will submit the assignment as yourid_assignment1.playground via Canvas. Canvas may convert this to a zip, but that is fine, so long as the extracted file has the correct naming convention.


Last modified: 08/21/18 by Sarah Abraham theshark@cs.utexas.edu