Commit 3abd4fa

mo khan <mo@mokhan.ca>
2022-11-15 17:54:23
add assignments and projects for course
1 parent 1e01cb0
assignments/1.md
@@ -0,0 +1,1 @@
+Assignment 1 – choose ONE exercise each from Chapters 2 and 3
assignments/2.md
@@ -0,0 +1,1 @@
+Assignment 2 – choose ONE exercise each from Chapters 4 and 5
assignments/3.md
@@ -0,0 +1,1 @@
+Assignment 3 – choose ONE exercise each from Chapters 6, 7, and 8
assignments/4.md
@@ -0,0 +1,1 @@
+Assignment 4 – choose ONE exercise each from Chapters 10, 11, and 12. There are no chapter end exercises for Chapter 9.
assignments/5.md
@@ -0,0 +1,1 @@
+Assignment 5 – choose ONE exercise each from Chapters 13, 14, 15, and 16
assignments/6.md
@@ -0,0 +1,1 @@
+Assignment 6 – choose ONE exercise from Chapter 17
projects/1/GooddocsF.cpp
@@ -0,0 +1,131 @@
+//: GoodDocs.cpp
+
+/* 
+ Title: GoodDocsF.cpp
+ Description: Temperature Conversion Program
+ Date: December 8, 2013
+ Author: Richard S. Huntrods
+ Version: 1.0
+ Copyright: 2013 Richard S. Huntrods
+*/
+
+/*
+ DOCUMENTATION
+ 
+ Program Purpose:
+ 	Demonstrate proper format for documentation, test plans and comments.
+ 	Also demonstrate user prompts, keyboard input, simple calculations and output,
+ 	specifically converting temperatures from F to C.
+
+ Compile (assuming mingw compiler and opened command prompt): g++ -o GoodDocsF GoodDocsF.cpp
+ Execution (in a Command Prompt window): GoodDocsF.exe (or just GoodDocsF)
+ 
+ Classes: none
+
+ Variables:
+ 	input_units (char) = C or F to designate temperature units for the supplied input temperature.
+ 	output_units (char) = C or F to designate temperature units desired for the output conversion,
+ 	input_temp (float) = real (decimal) number supplied by user which is the input temperature.
+ 	output_temp (float) = calculated output temperature in output_units as a real (decimal) number.
+
+ Formulae:
+ 	The formula for converting temperatures from Fahrenheit to Celcius is:
+ 	T(C) = (T(F) - 32.0) * 5.0 / 9.0;
+ 	The formula for converting temperatures from Celcius to Fahrenheit is:
+ 	T(F) = (T(C) * 9.0 / 5.0) + 32.0
+
+ 	It is important to use decimal numbers especially in the division to avoid integer devision.
+ 	It is also important use use the parenthesis to enforce calculation order.
+*/
+
+/*
+ TEST PLAN
+ 
+ Normal case 1:
+ 	>What is the input temperature? 32
+ 	>What are the units of the input temperature (C for Celcius or F for Fahrenheit)? F
+ 	>Your input temperature is 32F which is 0C.
+
+ Normal case 2:
+ 	>What is the input temperature? 100
+ 	>What are the units of the input temperature (C for Celcius or F for Fahrenheit)? C
+ 	>Your input temperature is 100C which is 212F.
+
+ Bad Data case 1 (temperature out of range):
+ 	>What is the input temperature? -4000
+ 	>What are the units of the input temperature (C for Celcius or F for Fahrenheit)? C
+ 	>Your input temperature is -4000C which is out of range (less than -273.15C or -416F)..
+
+ Bad Data case 2 (incorrect units):
+ 	>What is the input temperature? -40
+ 	>What are the units of the input temperature (C for Celcius or F for Fahrenheit)? Q
+ 	>The units you have specified are not one of C (Celcius) or F (Fahrenheit).
+
+ Discussion:
+ 	The program accepts any integer or decimal input temperature and a unit character which must be either C, c, F or f.
+ 	The program then prints the input temperature as well as the temperature converted into the non-input units.
+ 	Temperature range is from -273C (-415F) to any positive number.
+ 
+*/
+
+#include <iostream> // Stream declarations
+using namespace std;
+
+int main(void) {
+	char input_units, output_units;
+	float input_temp, output_temp;
+	int error = 0;
+
+	// request and obtain name
+	cout << "What is the input temperature? ";
+	cin >> input_temp;
+
+	// request and obtain age
+	cout << "What are the units of the input temperature (C for Celcius or F for Fahrenheit)? ";
+	cin >> input_units;
+
+	// convert input units to upper case
+	input_units = toupper(input_units);
+
+	// check input_units for acceptable response; perform appropriate conversion if acceptable and print error message if not
+	if(input_units == 'C') {
+		// display input
+		cout << "Your input temperature is " << input_temp << input_units;
+
+		// range check input_temp
+		if(input_temp < -273) {
+			// disply out of range error message
+			cout << " which is out of range (less than -273C or -416F)." << endl;
+		}
+		else {
+			// convert from Celcius to Fahrenheit
+			output_units = 'F';
+			output_temp = (input_temp * 9.0) / (5.0 + 32.0);
+
+			// display converted output
+			cout << " which is " << output_temp << output_units << "." << endl;
+		}
+	}
+	else if(input_units == 'F') {
+		// display input
+		cout << "Your input temperature is " << input_temp << input_units;
+
+		// range check input_temp
+		if(input_temp < -416) {
+			// out of range
+			cout << " which is out of range (less than -273C or -416F)." << endl;
+		}
+		else {
+			// convert from Fahrenheit to Celcius
+			output_units = 'C';
+			output_temp = (input_temp - 32.0 * 5.0) / 9.0;
+
+			// display converted output
+			cout << " which is " << output_temp << output_units << "." << endl;
+		}
+	}
+	else {
+		// display input_unit error message
+ 		cout << "The units you have specified are not one of C (Celcius) or F (Fahrenheit)" << endl;
+	}
+} ///:~
projects/1/README.md
@@ -0,0 +1,33 @@
+Project Instructions
+
+You will find detailed step-by-step instructions below on downloading and installing the compiler.
+However, the basic steps of the project are as follows:
+
+1. Download and install the MinGW compiler for C++.
+1. Compile the code file provided (GooddocsF.cpp).
+1. Test the resulting executable file. [The program is designed to produce temperature conversions.]
+1. Debug the program by correcting minor errors that have been deliberately placed in the temperature calculation formulas. Note: The formulas coded in the program are incorrect. The formulas in the program documentation at the start of the program are correct.
+1. Recompile the corrected code and retest the program.
+1. Submit the uncorrected and corrected versions of the program.
+
+
+Coding, Compiling, and Debugging
+
+1. Download the C++ code GooddocsF.cpp into your working directory.
+1. In the working directory compile the file GoodDocsF.cpp using the following command:
+
+    g++ -o GoodDocsF.exe GoodDocsF.cpp
+
+1. In the working directory, type GoodDocsF and observe the results. Note: the original program was purposely designed to produce temperature conversions with incorrect results.
+1. Open the file GoodDocsF.cpp in a text editor (e.g., Notepad) and modify the formulas as required to ensure correct output.
+1. Save the corrected file as GoodDocsF2.cpp in the working directory.
+1. Compile GoodDocsF2.cpp and generate GoodDocsF2.exe using the following command:
+
+    g++ -o GoodDocsF2.exe GoodDocsF2.cpp
+
+1. Run GoodDocsF2.exe by typing the command GoodDocsF2 to verify the output corresponding to the correct result.
+1. Submit the following complete programs to your Academic Expert for marking. Place all programs or files into one zipped folder, such as project1.zip, and submit it using the drop box on the course home page.
+  * GoodDocsF.cpp
+  * GoodDocsF.exe
+  * GoodDocsF2.cpp
+  * GoodDocsF2.exe
projects/2/README.md
@@ -0,0 +1,221 @@
+Project 2: Introduction to Programming in Python
+
+Introduction
+The purpose of this project component is to provide a first experience in the actual writing of computer programs. Using a relatively simple introductory scripting language (Python), you will create program code in an editor (Notepad), save it to your disk, and run it from the command line prompt.
+
+You will gain experience in planning, writing, debugging, documenting, and running simple programs. Learning Python serves as a convenient stepping-stone to more complex object-oriented languages, such as Java.
+
+In this project, you will use online resources, including downloadable Python tools and tutorials.
+
+Before writing programs, it is useful to plan the programming steps and actions by writing an algorithm. An algorithm is a set of plain English language commands or steps, each of which is then replaced by the appropriate command line for the programming language used. This technique becomes less useful when using complex object-oriented languages such as Java, but may be helpful in the early stages of learning to design programs. You will write algorithms for your first two programming exercises in this project.
+
+The project will be graded for completeness and correct functioning of programs.
+
+Acquiring the Tools
+Download and install Python version 2.2 or higher by following the instructions at the Python download site.
+
+The downloaded file will be called Python-2_2.exe. After downloading, run this file to complete the installation. You can view the installed components from your "Start" list.
+
+Writing Algorithms
+In the traditional approach to programming, the program is seen as a series of steps, which may include branches and loops. A branch occurs when a program may go in two or more different directions, depending upon a logical condition or a choice made by the user. A loop is a situation where a particular step, or series of steps, may be repeated until a certain condition or choice occurs.
+
+The following simple example of an algorithm includes both elements, and describes a simple program for performing addition or multiplication.
+
+Step 1—display the program name "Addition and Multiplication"
+
+Step 2—display the options menu "(A)dd, (M)ultiply"
+
+Step 3—request and store input of user choice A or M as "choice"
+
+Step 4—if "choice" does not equal "A" or "M", go to Step 9
+
+Step 5—request and store the first number to be used as variable X
+
+Step 6—request and store the second number to be used as variable Y
+
+Step 7—if "choice" = "A" go to Step 11
+
+Step 8—if "choice" = "M" go to Step 13
+
+Step 9—display message "Choose A or M"
+
+Step 10—go to Step 3
+
+Step 11—display "Sum is" X+Y
+
+Step 12—go to Step 3
+
+Step 13—display "Product is" X*Y
+
+Step 14—go to Step 3
+
+Writing, Storing, and Running Python Programs
+The actions involved in creating and running Python programs are relatively simple:
+
+Input the code using Notepad, and save the file as *.py (e.g., prog1.py). Save your programs in the Python folder on your hard disk.
+
+Open the MS-DOS prompt window.
+
+Change directory from Windows to Python22 (enter "cd\", followed by "cd python22").
+
+Run the Python interpreter on your program by typing python filename.py, where "filename" is the actual name of your saved *.py file (e.g., python prog1.py).
+
+Learning Python
+Go to A Beginner’s Python Tutorial, and work through the first seven lessons.
+
+Please note that the tutorial describes running programs for an earlier version of Python, and follows:
+
+"Edit" menu-> "Run Script"
+
+In later versions of Python, programs are run as follows:
+
+"Run" menu-> "Run Module" (or simply hit F5)
+
+Note: If you need more help, the internet has several instructive sites, for example, www.learnpython.org/.
+Programs
+The programs you will write for this project are copied with permission, or adapted from, the exercises in A Beginner’s Python Tutorial.
+
+Each program should be written, tested, and debugged. The first two programs should also be fully commented, with each line documented by a descriptive comment. The remaining programs should have a single comment line at the beginning to describe the function of the program. All programs should start with a display of your name, student id#, and the program number and name. When storing the files, name them as prog1.py, prog2.py, etc.
+
+EXAMPLE OF AUTHOR/PROGRAM INFORMATION OUTPUT
+Program author: B. Rubble
+
+ID#: 1234567
+
+Program 1—Math Functions
+
+PROGRAM 1—MATH FUNCTIONS
+Write an algorithm for a program that shows the use of all six math functions. Write, test, and debug the program using Python.
+
+SAMPLE OUTPUT (not including author/program information)
+
+ADDITION: 2+2=4
+
+SUBTRACTION: 4-2=2
+
+MULTIPLICATION: 4*2=8
+
+DIVISION: 4/2=2
+
+EXPONENT: 2**3=8
+
+REMAINDER: 5%2=1
+
+PROGRAM 2—USING INPUT
+Write an algorithm for a program that receives, as input from the user, 2 string variables and 2 integer variables; then joins together and displays the combined strings; and finally multiplies the two numbers on a new line. Write, test, and debug the program using Python.
+
+SAMPLE OUTPUT (not including author/program information)
+
+Input string 1? Billy
+
+Input String 2? Bob
+
+Input integer A? 23
+
+Input integer B? 2
+
+BillyBob
+
+46
+
+PROGRAM 3—LOOPS AND IF CONDITIONS
+Write a program that requests a password after the author/program information is displayed. Make the password "hello". The program should then ask the user for their name: if the name entered is the same as your name, the program should respond with "What a great name!"; if they enter "Madonna" or "Cher", the program should respond "May I have your autograph, please?". For any other input, the program should respond with "(input name), that’s a nice name".
+
+SAMPLE OUTPUT (including author/program information)
+
+Program author: Barney Rubble
+
+ID#: 1234567
+
+Program 3—LOOPS AND IF CONDITIONS
+
+Password? unicorn
+
+Password? opus
+
+Password? hello
+
+Welcome to the second half of the program!
+
+What is your name? Barney
+
+What a great name!
+
+ 
+
+ALTERNATE OUTPUTS
+
+What is your name? Cher
+
+May I have your autograph, please?
+
+What is your name? Bill
+
+Bill, that’s a nice name.
+
+PROGRAM 4—FUNCTIONS
+Rewrite the area.py program (shown below, or in the Creating Functions section of the tutorial) so that it has separate functions for the perimeter and area of a square, a rectangle, and a circle (3.14 * radius**2). This program should include a menu interface that has ‘exit the program’ as one of its choices.
+
+SAMPLE PROGRAM EXECUTION
+
+Area.py
+
+#This program calculates the perimeter and area of a rectangle
+
+print "Calculate information about a rectangle"
+
+length = input("Length:")
+
+width = input("Width:")
+
+print "Area",length*width
+
+print "Perimeter",2*length+2*width
+
+ 
+
+SAMPLE OUTPUT (not including author/program information)
+
+CALCULATIONS MENU
+
+1) AREA (SQUARE)
+
+2) AREA (RECTANGLE)
+
+3) AREA (CIRCLE)
+
+4) PERIMETER (SQUARE)
+
+5) PERIMETER (RECTANGLE)
+
+6) PERIMETER (CIRCLE)
+
+7) EXIT
+
+INPUT MENU CHOICE (1,2,3,4,5,6 OR 7)? 2
+
+YOU HAVE CHOSEN AREA (RECTANGLE)
+
+INPUT WIDTH? 8
+
+INPUT LENGTH? 4
+
+AREA IS 32
+
+INPUT MENU CHOICE?
+
+Packaging and Submitting
+When submitting your project, use WinZip or a compatible program to compress all the required files into a single archive. There should be four files in total: prog1.py, prog2.py, prog3.py, and prog4.py.
+
+Grading
+All programs must be fully debugged, and must run without errors. No marks will be given for programs that do not run. Marks are assigned as follows:
+
+Program 1—10% (7% for program, 3% for algorithm)
+
+Program 2—20% (15% for program, 5% for algorithm)
+
+Program 3—30%
+
+Program 4—40%
+
+total—10%
projects/3/README.md
@@ -0,0 +1,88 @@
+Project 3: Data Modeling and Normalization
+
+Overview
+The task in this project is to design a normalized database that could be used to collect and store information for a video rental outlet. The database should be structured to support tasks such as:
+
+tracking rentals by title and by customer;
+
+producing reports, such as rentals due on a certain date;
+
+categorizing rentals by media type (e.g., Blu-Ray, DVD, Game).
+
+The assignment does not require you to produce examples of the reports listed, but only that the database be correctly structured to allow the query and reporting features of a DBMS, such as Access, to work properly.
+
+You will need to collect information about several titles in each category, which can be done online, at your local video store, or from your personal media collection. You will be given an initial, un-normalized field list of data items to be tracked, which you will normalize into the appropriate separate tables.
+
+The database students will prepare in this project is somewhat simplified in comparison to a real-world application. For example, only brief customer address information is included, to reduce the amount of data input required for the project. We have also simplified the example in terms of structure; ignoring, for example, the complexities of a real-world video outlet, such as varying rental periods for different products.
+
+The initial field list does not include all of the appropriate key fields for the tables that will be created, so suitable key fields should be added to the tables as required.
+
+This project is most easily completed using MS-Access; for a detailed discussion of the other options for completing the Project, please see "Alternatives to MS Access" below.
+
+Project Details
+The following is a list of essential data items to be recorded. As noted above, additional fields may be required as keys for the tables you will create from these fields.
+
+date of rental
+
+due date
+
+media item title
+
+media item category
+
+category description
+
+category code
+
+customer ID#
+
+customer lastname
+
+customer firstname
+
+customer address
+
+If only a single table were made from all the fields listed above, the result would be a system in which every rental would have to include duplicate customer and media item details. In addition to wasting input time duplicating data, such a system would also be highly prone to error, because any change to customer data (a change of address, for example) would also result in different records showing different content for the same fields, unless every historical record for that customer was updated.
+
+The relational database model was designed to solve those problems by identifying key data entities, separating them into their own tables, and relating the tables using foreign keys. (The foreign key is usually the primary key from one table, placed in one or more other tables to create linkages.)
+
+This allows for customer details, for example, to be recorded once, in a table reserved for that purpose, and referenced in other tables by a unique identifier (key), such as Customer ID#.
+
+Your task is to create a simple relational database from the field list above. The required tables are Customers, Media, Categories, and Rentals; each of which should be properly provided with a primary key, and each of which should be related to other tables as required.
+
+All four database tables should be populated with records as follows:
+
+Customers—at least 10
+
+Categories—three records, one describing each of the media types: DVD, Blu-Ray, or Game
+
+Media—at least 30 records, representing a selection of DVD movies, Blu-Ray movies, and Games.
+
+Rentals—at least 20 records.
+
+Marking Criteria
+This project represents 15% of your final grade, and will be graded according to the following criteria:
+
+DATABASE NORMALIZATION TABLES (50 marks)
+There should be four tables, with the correct fields.
+For each missing or incorrectly placed field, 10 marks will be deducted.
+
+KEY FIELDS (40 marks)
+Key fields have been correctly assigned to each table.
+For each missing or incorrect key field, 10 marks will be deducted.
+
+OTHER FEATURES (10 marks)
+
+Use of a Query, Use of Input Form, OR Report, OR use of Field Attributes (i.e., Input Mask, Caption, or Default Value, for projects completed using MS-Access), OR provision of annotated SQL statements (as described below under ALTERNATIVES TO USING MS-ACCESS).
+
+Using MS-Access
+You now have the option to download and install MS-Access (free to SCIS students).
+
+For help with the basics of MS-Access, refer to the tutorials and step-by-step directions for basic operations and functions that are included in the Help features of your MS Access software. Search "getting started" in the help utility, and look at the sections on Access basics, creating tables, and producing queries. This approach will provide help that is specific to your particular version of the software. If you have one available, you may also want to refer to a general MS Office desk reference, and review the sections pertaining to basic Access operations.
+
+Alternatives to MS-Access
+To complete the project without using MS-Access or another DBMS, you will need to create the correctly normalized tables in some other application (e.g., Excel or Word), including the required fields, and with the appropriate key fields clearly identified. The tables should be populated with data, as required and described elsewhere in the project instructions.
+
+In place of applying the extra DBMS functions (forms, queries, or field attributes) listed as part of the project requirements, students pursuing this approach will submit three SQL statements; each documented or annotated to describe the expected query results. The most basic approach to this requirement would be to produce three variations of the SELECT statement, each designed to produce a different list of rentals according to specified criteria. The criteria could relate to a customer, a specific media category, a title (for example, all rentals for a certain date, title, or customer), or some other aspect of the data.
+
+A general description of SQL may be found by checking the index listings for SQL in your textbook, and reviewing the pages listed.
README.md
@@ -1,5 +1,3 @@
 # COMP 200
 
 # 1.1 Introduction to Computer Science
-
-