For this assignment you are expected to use: the line-at-a

SY110 Homework Alpha: ________ Name: ____________________
Page 1 of 2
Collaboration Policy: Default
MIDN Last, F.
choose one: □ None □ XS110 □ EI with:
(or more)
□ MGSP
□ Discussed with: ____________________________
Homework: /SY110/Cyber Battlefield/Programs – I/O
For this assignment you are expected to use:
http://rona.academy.usna.edu/~sy110/resources/interpreter.html
the line-at-a-time JavaScript interpreter,
http://rona.academy.usna.edu/~sy110/resources/batchInterpreter.html
the batch JavaScript interpreter, or the JavaScript console
included with your browser.
1. [ 20 / 15 / 10 / 0 ] Write a JavaScript statement that
produces the depicted alert box. Note: Use the line-at-a-time
interpreter (URL above) to experiment and make sure your
solution works!
2. [ 20 / 15 / 10 / 0 ] Copy and paste
the following program into the batch
interpreter and run it. Then modify it so
that the number of processors is entered
by the user rather than set to 4 in the
code (this is referred to as being “hard
coded”), similar to the diagram to the
right.
Annotate the code below to show how you modified it!
var licenseCostPerCore = 1800 ;
var coresPerProc= 12 ;
var numProcs = 4 ;
var numCores = coresPerProc * numProcs ;
var totalCost = numCores * licenseCostPerCore ;
alert( totalCost );
SY110 Homework
Collaboration Policy: Default
Page
2 of 2
3. [ 30 / 25 / 15 / 0 ] Copy and paste the following program into the batch interpreter and run it.
Modify the program so that the user can enter their own 4 letter word which is converted to
binary for them.
Hint: .toString( 2 ) changes the value in front of it to binary, don’t change that part.
Annotate the code below to show how you modified it!
var b = "";
b = b + 'U'.charCodeAt( 0 ).toString( 2 );
b = b + 'S'.charCodeAt( 0 ).toString( 2 );
b = b + 'M'.charCodeAt( 0 ).toString( 2 );
b = b + 'C'.charCodeAt( 0 ).toString( 2 );
alert("USMC in binary is: " + b);
4. Complete the following after exploring the below URL:
view-source://rona.academy.usna.edu/~sy110/lec/prgmIO/hw/classOf.html
Hint: Use the source, MIDN.
Note: Complete the below by only changing the data you input into the program, DO NOT alter
the source code.
a. [ 5 / 3 / 2 / 0 ] What number did you want as part of the end result (your goal)?
b. [ 10 / 8 / 5 / 0 ]
What was your input to the first prompt to achieve your goal?
c. [ 15 / 10 / 5 / 0 ]
What was your input to the second prompt to achieve your goal?