

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Professor: Stotts; Class: Introduction to Programming; Subject: COMPUTER SCIENCE; University: University of North Carolina - Chapel Hill; Term: Fall 2008;
Typology: Assignments
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Fall 2008
Due: Mon. Sept 22 at 12:00 midnight For this assignment you will create a web page with an embedded JavaScript program. You will store this program as an HTML file in your UNC web space, and you will give it an 8-character or more filename that only you know. Then we can retrieve, run, and grade it by pointing our browser www.unc.edu/~ yourOnyen/yourSecretName.html but no one else can see it without making a really good guess at what you named it. This program will exercise the concepts you have been learning to date. It will require you to write a loop, use conditional (if) statements, do input via prompt, do output via alert, create named constants, produce arithmetic expressions, do assignment to variables.
Use a simple text editor to create this program. Do not use Web generation tools. You are to write a program that will act like a simple 5-function calculator. The user is able to get 5 different kinds of arithmetic operations: addition, subtraction, multiplication, division, and square roots. When the program first runs, it will ask the user to enter a number 0 to 5. Then it will perform the operation corresponding to that input value based on this table:
This assignment will require you to use a loop, conditional statements (if then else), input (prompt), output (alert), assignment statements, and arithmetic expressions. Here is a basic “algorithm” (recipe for the computation): // declare the variables you need // make a main loop // first get input item (prompt), tells what operation to do // if this item is 0, you are done // if this item is not 0, then do a single operation: // get more input (prompt)… get the numbers to use // apply the proper arithmetic to the number(s) // print the result (alert) // end of main loop… (do it again) // print a message saying its all done
Use the basic HTML file structure we developed in class for the program. This is one with the