Download Introduction to Computer Science - Java Script Program | CMSI 182 and more Assignments Computer Science in PDF only on Docsity! CMSI 182 I N T R O D U C T I O N T O C O M P U T E R S C I E N C E Fall 2006 Assignment 0921 Let’s try our hand at writing some simple JavaScript programs. If you get stuck, you can try looking things up on the Web, or else just ask me. Not for Submission Read Chapter 3 in the Brookshear book. For Submission Submit all work on hardcopy at the beginning of our September 21 class. For the following simple algo- rithms, supply the following: 1. A step-by-step breakdown of the algorithm in plain English 2. A JavaScript program that performs the algorithm for some input values of your choosing, stored in variables at the beginning of the program Use the JavaScript scratch page to test your JavaScript code. The algorithms are: • Convert inches to centimeters (there are 2.54 centimeters per inch). • Calculate the average (mean) of 5 numbers. • Make change: determine the number of quarters, dimes, nickels, and pennies needed for a given cent total. For example, 72 cents uses 2 quarters, 2 dimes, 0 nickels, and 2 pennies; 15 cents uses 0 quarters, 1 dime, 1 nickel, and 0 pennies. Hint: To grab only the integer portion of a quotient, use parseInt(). For example, parseInt(72 / 25) is 2. Extra Credit Figure out how to use the entry fields in the JavaScript scratch page so that you can perform your algo- rithms based on information provided by the user in those fields. Submit those versions of the algorithm in hardcopy along with the main portion of the assignment. Hint: The initial content that’s in the JavaScript scratch page’s text area provides a starting point.