Exam2ReviewAnswers

Exam2ReviewAnswers - and the total of numbers entered. At...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Exam 2 Review Answers A->~B = If I ate potatos then I did not eat beans. A ^ B = I ate potatos or I ate beans. I did not eat potatos and I ate beans = ~A ^ B I ate beans or I did not eat potatos = B v ~A Make sure you know all the symbols and read the questions carefully. Given a variable x, if x equals 10 output “that’s great number” otherwise output “not so great, but ok” if (x==10) { alert(“that’s a great number”); } else { alert(“not so great, but ok”); } Given a variable count Write a loop that outputs the numbers 1 to count on separate lines in bold var counter=0; while (counter<=count) { counter++; document.write(“<b>”+counter+”</b>”); } var a = 1; var b = 3; var z = 12; while (a<b) { a+=2; z--; } z is 11 after this code runs. While doing these problems write the down the current values of the variables as you go. Your notes may look like this, a=1 b=3 z=12
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
check loop, true a=3 z=11 check loop, false
Background image of page 2
Ask the user for a set numbers one at a time. Keep track of the count of numbers entered
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: and the total of numbers entered. At the end output the total, count and average. Assume the user will enter at least one number. (Exam question will be more difficult than this, study javascript 2 and 3 assignments) 1. Start 2. Create variables usernumber, count, total, average,userconfirm 3. Set count equal to 0, total equal to 0 4. Ask user for usernumber 5. Add usernumber to total 6. Add 1 to count 7. Ask user for userconfirm 8. If userconfirm is true go to step 4 9. Set average = total/count 10. Output total, count, average 11. End &lt;html&gt; &lt;head&gt;&lt;title&gt;My awesome answers&lt;/title&gt;&lt;/head&gt; &lt;body&gt; &lt;script type=text/javascript&gt; var usernumber,total=0,count=0,userconfirm,average; do { usernumber =1*prompt(enter number,); total+=usernumber; count++; userconfirm=confirm(continue?); } while (userconfirm==true) document.write(total is + total + average is + average+ count is + count); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;...
View Full Document

Page1 / 4

Exam2ReviewAnswers - and the total of numbers entered. At...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online