Instructor: David R. Brooks, PhD

e-mail: brooksdr@drexel.edu
WWW: www.pages.drexel.edu/~brooksdr
Office: at Bossone prior to class or by appointment
Time: Thursday, 6:00-8:50pm
Place: Bossone 709
Tequired texts: NOTE: Check www.abebooks.com for good prices on these texts, new and used.
        David R. Brooks, An Introduction to HTML and JavaScript for Scientists and Engineers, Springer, 2007
        ISBN 978-1-84628-656-8

        David R. Brooks, Introduction to PHP for Scientists and Engineers, Springer, 2008
        ISBN 978-1-84800-236-4

Course Description

This course provides an introduction to programming and problem solving. Rather than using a "traditional" programming language such as C or C++, it uses the HTML/JavaScript/PHP environment. This approach recognizes the dominant role HTML and JavaScript play in today's online world, and takes advantage of the fact that JavaScript and PHP include the most important features of modern structured programming languages. HTML is a basic Web development tool that provides the user interface for problem solving. JavaScript is a fully featured client-side language that can be used to solve a wide range of computing problems, including problems from science and engineering. JavaScript's inability to access information stored on a remote server is a limitation that can be overcome by using a server-side language such as PHP. A brief introduction to PHP will demonstrate how to read and write files on a server.

Students are expected to bring to this class their own suggestions for computing problems that are relevant to their current studies. By the end of the course, students will be able to create their own online applications for solving a wide range of computing problems. Because the course emphasizes general programming principles, it prepares students to learn other languages as needed. Not so incidentally, a working knowledge of HTML, JavaScript, and PHP is a highly marketable skill.

Course Outline (preliminary and subject to change)

Week 1, September 24
Introduction to HTML elements
HW Assignment due in class, Week 2:
1. "Improve" your web site with a little content and some color, one or two photos, etc. You should try to use some style settings, too.
2. Bring at least one proposed programming problem to discuss in Week 2 class.
3. Please send me an e-mail with the URL for your website.
Week 2, October 1
HTML tables, lists, and forms
HW Assignment due in class, week 3:
1. First of all, remember that posing a programming problem is required as part of the first week's assignment. The due date can be extended to give everyone a chance to come up with a suitable problem.
2. Exercise 2.4 at the back of your text.
3. Exercise 3.1 at the back of your text. Some people have experienced problems with submitting forms using Outlook Express. Someone at Korman may be able to help with this. I think this is a matter of setting appropriate options in Outlook, rather than an HTML problem. If you continue to have problems with this, please let me know sooner rather than later!
4. Exercise 3.2 at the back of your text.
Link to "Cardiac output" code
Week 3, October 1-5
Introduction to JavaScript
HW Assignment due in class, week 4:
1. Exercise 4.4 at the back of your text.
There is an error in the problem statement because it doesn't define k. k=1 for a leap year and k=2 otherwise. Also, you should check your code by converting the day number back into a calendar date and displaying the result. The algorithm for doing this is:
If n<32, m=1 and d=n
Otherwise, m=INT[9*(k+n)/275 + 0.98] and d=n-INT(275*m/9) + k*INT[(m+9)/12] + 30
Be careful to translate this algorithm into correct JavaScript syntax. For example, you cannot use a square bracket as part of an arithmetic expression. And, "INT" expresses a mathematical operation -- it is not a JavaScript "thing."
2. Exercise 4.7 at the back of your text.
3. Exercise 4.15 at the back of your text.
My solutions to Week 2 HW, plus in-class exercise:
Exercise 3.1
Exercise 3.2
Exercise 2.4
Rectangular Rule integration
Week 4, October 8
Introduction to JavaScript
Week 5, October 15
JavaScript Functions
Homework due by class, October 22
1. Exercise 5.5 in your text. Note that because of the peculiarities of the sort() method, the array should already be sorted in ascending or descending order so you don't have to sort it in order to find the median. Make sure your code works for arrays with even or odd numbers of elements.
2. Exercise 5.6 in your text.
3. Exercise 5.7 in your text.
My solutions to HW#3:
dayOfYear.htm
population.htm
pressure.htm
In-class exercises:
ArrayMean1.htm
ArrayMean2.htm is a somewhat fancier solution. It allows the user to enter array elements in an input field, separated by commas. The split() method (not discussed in the text) is then applied to split the string into an array of values. These values are considered to be strings, so they must be converted to numbers using parseFloat().
ArrayMean2.htm
For this code, the form tag is apparently required for some browsers but not for others. I learned this only when the code worked without the form tag in AceHTML but not when I uploaded it to dunx1 and opened it in Firefox.
CheckboxCount.htm
Week 6, October 22
Building complete HTML/JavaScript applications link to code from class last night. There wasn't anything wrong with this code. I just needed to push the "back" button after the document.write() display. Note that document.write() (or alert()) will display the contents of an array, with the elements separated by commas.
HW due October 29
Exercises 6.2, 6.7 in your text
Week 7, October 29
HW due November 5
Exercise 6.9 and 6.11 in your text.
histogram.htm
reverseArray.htm
statistics.htm
DateCheck.htm
MathFunctions.htm
Introduction to the PHP environment
Week 8, November 5
Remote file access with PHP
NOTE: deadline for HW due Nov. 5 extended to Nov. 7. Note that there is an error in Problem 6.9. The second line after N_has_disease - ... should be = (NWD*PD)/[NWD*PD+NND*(1-PD)]

HW due November 12.
Create a data file with first name, last name, ID, and phone number, like this:

First Last ID Phone
Sam Malone 00335 5551234986
Diane Chambers 10398 9992349876
Norm Peterson 20987 8889994444
...

Write HTML and PHP documents that will search for and display entries in this data file. Your HTML interface should look like this:
Week 9, November 12
HW due November 19
Exercises #8 and #16 in your PHP text. For exercise #16, write the output to a data file as well as displaying it on your monitor. You will need to find out where you are allowed to write files on your computer. If you are using the Apache server, you will probably NOT be able to write files in /wamp/www. If you are not allowed to write to the destination you have chosen, you will get some obscure and unhelpful error message about resources not being available. See Document 1.7b in your PHP text for what works on my Windows XP computers. Use this data file: philtemp2001.txt as your input file.
Week 10, November 19
Problems to do in class:
(1) Pennsylvania currently makes it relatively attractive for homeowners to install solar photovoltaic systems, by offering a “rebate” based on the size of the system. This is in addition to federal incentives. Here is some information:

Typical system size, 5kW
Typical cost per watt, $7-$9/W
PA rebate, $2.25/W, maximum of 35% of system cost
Federal tax credit, 30% of total system cost (the cost paid to the system installer)

The PA rebate is subject to federal tax, at a rate that depends on your tax bracket. You can assume 25%. PA may also tax its own rebate (because it’s reported as "income" on a federal 1099 form), at the flat PA personal income tax rate of 3.07%. Finally, PA also offers a 15% credit against your PA income taxes. However, this credit cannot be more than the tax you owe for the year in which the credit applies. That is, this credit cannot be more than 3.07% of your taxable income.

Write a JavaScript application that allows a homeowner to enter information about a solar PV system and your PA taxable income, and then calculates the "true" system cost after receiving federal and PA incentives and after paying taxes on those incentives.

(2) For Exercise 8 in your PHP text, which you have already done, modify your code so that PHP writes the output from your application to a comma-delimited text file that can be imported into a spreadsheet (use a .csv extension for the file name).
HW due December 3
PHP Exercise 12
      Here's how to update the balance for each month. Calculate the interest due on the current balance (current balance x loan_rate/12) and add that to the current balance. Then subtract the monthly payment. If you (as the lender) are reinvesting each month's payment as you receive it, at each month you calculate the interest earned that month on what you have reinvested (current amount x investment_rate/12) and add that to your reinvestment account.

PHP Exercise 15
      Your output table should look like the one in your text. It will be easier to do one depreciation method at a time, rather than trying to write all the code at once (almost always a mistake!).

My code for PHP Exercises 8 and 16.
Week 11, November 26(Thanksgiving, no class)
Class project
Week 12, December 3
Class project

Grading

Homework, 40%; Class participation, 25%; Final project (possibly in the form of a take-home exam), 35%

Class policies

Class participation is important. Homework and other individual projects must represent your own work. In some cases, you may arrange to work jointly on class presentations or projects. If you make use of outside sources for code, you must acknowledge them.

Prior to the start of class, you must establish a basic Web page on Drexel's dunx1 computer or elsewhere. See this file. NOTE: This file may need to be updated. If I find problems I will try to fix them. If you find problems, please let me know. I will be available to help if you have questions. Prior to the start of class, this Web page does not need to include anything other than your name in plain (default) font. The point of this requirement is to minimize the amount of class time spent going over the purely mechanical process of setting up a Web page. You do not have to put a Web page on dunx1. If you already have a Web site on which you can post assignments for this class, that is OK. Here is the minimum HTML code you will need:

<html>
<head>
  <title></title>
</head>
<body>
Home page for [your name].
</body>
</html>

You will need an HTML/JavaScript/PHP editor for this course. In principle, you can use any text editor, even Notepad. However, a "real" script editor will make your life much easier. I use the freeware version of AceHTML, available from www.visicommedia.com. The only downside to this free software is that it may require you to install other software that you don't want. I have a very old version, when this wasn't a problem. Presumably you can uninstall whatever software you don't want to keep. You do NOT need any kind of more elaborate Web design software, such as FrontPage, but you can use it if you already have it. There are several freeware editors available online, but I haven't looked at them. If you bring a Windows laptop to class, you can copy my installation program for AceHTML 5.0, which is what I use. It is pretty old, so I have no idea whether it will work with Vista.

Starting roughly midway through the quarter, you will need access to a server that is running PHP. The easiest solution is to create a local server on your own desktop and/or laptop. Note that Drexel's dunx1 computer (on which your Drexel e-mail and possibly your web page reside) does NOT support PHP (or other server-based scripting languages). For Windows computers, you can download and install WAMP (Windows Apache server with MySQL and PHP). For Linux, use LAMP. For Macintosh, use MAMP. These are all free downloads. I have WAMP on my Windows XP computers and I found the installation to be very easy. In the past, I had problems with configuring PHP on the IIS server that comes with Windows. I have not tried MAMP, but it is reported to be easy as well. I have LAMP installed on my own Linux-based server at home, but I know virtually nothing about Linux.

4. I have added an "errata" page for your texts, which you can find here: http://www.pages.drexel.edu/~brooksdr/DRB_web_page/courses.htm. Note the comment about the syntax for internal document links on page 33. The link to all code in your text is also here. If you find any problems with any of these code links, please let me know.

Powerpoint presentations:
Chapter 1
Chapter 2
Chapter 3
Frames
Chapter 4(a)
Chapter 4(b)
Chapter 5
Chapter 6
PHP #1
PHP #2
PHP #3

Other Resources

These books aren't required for this course, but they are an essential investment if you continue to use HTML and JavaScript after this class. Of course, there is also a vast amount of online information about HTML and JavaScript. The book by Stauffer is no longer in print, but it was the first HTML book I ever read and is still a good source if you can find a used copy.

Thomas Powell, HTML: The Complete Reference, Third Edition, 2001, Osborne/McGraw-Hill, Berkeley, CA. ISBN 0-07-212951-4.

Thomas Powell and Dan Whitworth, HTML Programmer’s Reference, Second Edition, 2001, Osborne/McGraw-Hill, Berkeley, CA. ISBN 0-07-213232-9.

Thomas Powell and Fritz Schneider, JavaScript: The Complete Reference, 2001, Osborne/McGraw-Hill, Berkeley, CA. ISBN 0-07-219127-9.

Todd Stauffer, Using HTML 3.2, Second Edition, 1996, Que Corporation, Indianapolis, IN. ISBN 0-7897-0985-6.

There are a lot of books about PHP, too, but they generally do not address a science/engineering-oriented audience. In conjunction with the text for this course, you should be able to do what I did when I was learning PHP: using online sources. The source to which I always turn when I have a question is www.php.net/manual/en/index.php. This is not just a language reference, but also includes many examples of code using PHP functions, along with useful reader commentary.