CX 103 : Introduction to Computers

Assignment 18

Due: Wednesday, April 4

Reading



Continue reading Chapter 11: "JavaScript/JScript: Functions" in Deitel, Deitel & Nieto, Internet & World Wide Web: How to Program.
 
 


Programming Exercises

(Submit Solutions to Exercises 1 - 3 on Wednesday)

1) Create a JavaScript version of our MiddFee program that prompts users to input the annual percentage increase in Middlebury's Comprehensive Fee and the number of years in the future they wish to see the projected fee. The program should then display each of the years by date (e.g. 2002, 2003,...) and the corresponding projected fee in dollars.

2) Modify our JavaScript program which sums all the even integers from 2 to 200 to produce a program which sums all the even integers from 2 to N where N is a positive integer obtained by a prompt from the user.

3) Write a function maximum3 that returns the largest of three integers. Incorporate the function into a script that reads three values from the user and determines and displays the largest value.

4) (For Friday): Write a JavaScript function that implements the manipulation of the four digit number which is pat of the encryption scheme discussed in Assignment 17. The function receives a four digit integer, adds 7 mod 10 to each digit, and then swaps the first and fourth digit and the second and third digit. The function returns the resulting four digit integer.
 
 

5) (For Friday): Write a JavaScript program that simulates the tossing of a fair coin. The program should simulate 1000 tosses, report on the number of Heads and Tails and also report on the number of times during the 1000 flips when more Heads than Tails had been recorded.