EME 6930 Assignment #II:
Data and Decision-Making

Objective: Create an original program that uses multiple groups of controls (such as radio buttons, check boxes, etc.) and JS selection structures to collect data from a user, perform some kind of processing on those data, and provide some kind of qualitative response that depends upon the result of the data processing. Also, use dialog boxes to collect some appropriate text data from the user (prompt), and to display pop-up messages (alert) or to offer options to the user (confirm).

 
My daughter likes games and riddles and I like math. So, I took an old math riddle and will let Javascript do the math for you.

 

Follow the steps below on paper first (with a calculator). Then try it with the form.

 

 

Step 1: Think of a whole number between 1 and 9 and enter it into the box below (click the random button to get a random number entered), then click the submit button.

 

Now, Javascript will fill in the values to the next steps

Add 9
Multiply by 10
Add 18
Divide by 2
Add the first number you thought of
Multiply by 3
Add the digits of your answer. i.e. 216 = 2 + 1 + 6, which = 9.
Repeat until you get a single digit result
Multiply by 2
Subtract 11
Convert your number to a letter using the following method:
1='A', 2='B', 3='C', 4='D', 5='E', 6='F', 7='G', 8='H', 9='I', 10='J', 11='K', etc. up to 26='Z'
   

After the calculation is complete, think of an American State that begins with your letter.

Now think of a State that begins with the next letter of the alphabet

.

OK, do you think I can guess what states you are thinking of? Click the "Tell Me" button below when you are ready.

 

 

Notes: This form accepts the users name in the prompt and writes it near the bottom of the game.

The random number function uses the math.random() function, multiplies by 9 to get a number between .09 and .89, adds .5 to get a number that will round up (or down) to a number between 1 and 9

When the user submits the number, the form validates that they submitted a number, that the number was between 1 and 9 and that the number does not contain a decimal point.

The math fills in the rest of the form. It is mostly basic arithmetic, except for the parsing of the number to add the sum of the digits in step 8, which then checks to make sure the answer is a single digit - with the numbers 2 and 7, the return at that point is 25.

 
Of course, the final number is always 7, which translates to G which has to be Georgia (the only state that starts with G) and H is Hawaii, again, the only state that starts with H.
 
 
 
 
 
 
 
 

 

 
 
 
USF Blackboard University of South Florida Instructional Technology Site About Me, Gregory Motes My Previous Course Projects Current Course Projects USF Ph.D Home