The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 408 Weeks Ago, 5 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
JavaScript Homework 1
Question 1: Trace the execution of the following JavaScript code. For each of the document.write statements, list the output that would be displayed.
value1 = 14;
value2 = 8 - (3 + 2);
document.write("value1 = " + value1 + ", value2 = " + value2);
x = 99 / 2;
y = 99 % 2;
z = 99 % 3;
document.write("x = " + x + ", y = " + y + ", z = " + z);
x = 2 * 3 * 4 * 5;
document.write("x = " + x);
Verify your predictions by using the JavaScript Interpreter on ANGEL.
Question 2: Trace the execution of the following JavaScript code. For each of the document.write statements, list the output that would be displayed. Assume that the user enters the value 1024 at the prompt.
x = prompt("Enter a number", "");
document.write("Double " + x + " is " + (2 * x));
document.write("Double " + x + " is " + (x + x));
x = parseFloat(x);
document.write("Double " + x + " is " + (x + x));
Verify your predictions by using the JavaScript Interpreter on ANGEL.Â
Program Part 1:
Create a new web page called incomeTax.html. This page will ask the user for their income, and based on that income, calculate the amount of income tax they owe.
Use a prompt box to get the user's income.
Use if/else statements to calculate the amount of tax they owe, using the following rates:
Income
Tax Rate
$0 - $49,999.99 15%
$50,000 - $99,999.99 $7,500 + (20% of income > $50,000)
$100,000+ $17,500 + (25% of income > $100,000)
Display their income, tax rate, and amount of tax they owe. Use document.write() statements to do this.
Program Part 2:
Modify the above program to include a loop to allow the user to continue to calculate the tax for other incomes, until the user chooses to quit. What type of loop should you use for this?
Submit a .zip file with a text or Word document with your answer to Questions 1Â
Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â----------- -----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------. P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll