CX 103 : Introduction to Computers

Assignment 19

Due: Friday, April 6

Reading

 

Complete the reading of Chapter 11: "JavaScript/JScript: Functions" and begin reading Chapter 12: "JavaScript/JScript: Arrays" in Deitel, Deitel & Nieto, Internet & World Wide Web: How to Program.

 

 

Programming Exercises

Hand in on Friday

1) 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. Include the function in a program which receives the four digit integer from the user through a single prompt.

 

2) 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.