99 980
Assignments Done
98.2%
Successfully Done
In June 2021

# Answer to Question #3234 in AJAX | JavaScript | HTML | PHP for lee

Question #3234
line 9 /*
line 10 * Program designed to find how many of a series of video tracks
line 11 * will fit on a DVD the user is prompted to input the track lengths
line 12 * one by one. When the total exceeds the capacity of the disk
line13 * user is informed how many tracks this took
line 14 */
line 15 var input;
line 16 var total;
line 17 var capacity;
line 18 var count;
line 19 total = 0;
line 20 capacity = 120
line 21 count = 0;
line 22
line 23 input = window.prompt
line 24 (&lsquo;please enter a track length in minutes&rsquo;,&rsquo;&rsquo;);
line 25 input = parsefloat(input);
line 26 total = total + input;
line 27 while (total&lt;=capacity)
line 28 {
line 29 document.write(&lsquo;track length &lsquo; + input + &lsquo;&lt;BR&gt;&rsquo;)
line 30 count = count + 1;
line 31 input = window.prompt
line 32 (&lsquo;please enter a track length in minutes&rsquo;,&rsquo;&rsquo;);
line 33 input = parsefloat(input);
line 34 total = total + input;
line 35 }
line 36 document.writ
line 37 (&lsquo; the capacity was exceeded after &lsquo; + count + &lsquo; track(s) . &lsquo;);

(a) Lines 9 to 14 in Figure 1 are an example of an extended comment. What is the purpose of comments and how are they treated by the JavaScript interpreter?
(b) What do lines 25 and 33 do and what difference would it make if they were left out?
(c) Describe in detail what happens when the statement
document.write('Track length ' + input + '&lt;BR&gt;');
at line 29 is executed.

(d) Suppose the programmer accidentally missed out line 30. Explain what would be output in that case when the statement on lines 36 and 37 was executed.
(e) If the programmer also missed out line 21 (so that both lines 21 and 30 are missing) what would then be output when the statement on lines 36 and 37 was executed? Explain your answer.
(f) Suppose the braces {and } at lines 28 and 35 were left out. Explain what would happen if the program was executed and the user entered 10 when prompted.
0

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!