COMP2051 Assignment 1 – Review

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (2 votes)

For this assignment, please note that NO jQuery may be used. You must write everything in core JavaScript. If
you are working alone, do questions 4 – 21. If you are working in a pair, do the first three as well.
1) Display a message that says: Spike is a great dog!
2) Create a variable newAge that adds the values of age and years. Return the result.
3) Display a message that says: In 4 years Spike will be 6 years old
4) Create a prompt to allow the user to enter a new pet name. Save the information in a variable named
newPet. Then, display the followingmessage: Your dog, Spike, is brown. Your new pet will also be brown.
5) Use the write() method to display the following statement in an HTML document. Format the text as a
level three header with a horizontal rule underneath: Lions, and tigers, and bears …. oh my!
6) An employer wants you to create a program that will allow her to enter each employee’s name, hourly
rate of pay, number of hours worked in one week, overtime pay rate, payroll deductions (such as
medical insurance, savings, etc.), and tax rate. The program should output the employees gross pay
(before taxes and deductions), and net pay (after taxes and deductions) for each employee for one
week.
7) Create a web page that will run a JavaScript script as soon as the page loads, using the onload event. The
script should display the following: JavaScript rules!
8) Create two web pages. The first page should ask the user if he or she wants to see some pictures. When
the user responds positively, a new window should open displaying several images.
9) Create a web page that contains two buttons. When the first is clicked, the user will be prompted to
enter a first name, then a last name. These names will be concatenated to form a username with a dot
between the first and last names. The second button will prompt the user for a nickname.
10) Declare variables c, thisIsAVariable, q76354 and number. var c, thisIsAVariable, q76354, number;
11) Display a dialog asking the user to enter an integer. Show a default value of 0 in the text field.
12) Convert a string to an integer, and store the converted value in variable age. Assume that the string is
stored in stringValue.
13) Create a program that evaluates a variable. If the variable number is not equal to 7, display “The variable
number is not equal to 7” in a message dialog.
2
14) Output a line of XHTML text that will display the message “This is a JavaScript program” on one line in
the XHTML document.
15) Output a line of XHTML text that will display the message “This is a JavaScript program” on two lines in
the XHTML document. Use only one statement.
16) Write a complete program that calculates and prints the products of three integers.
17) Write a javascript statment to accomplish each of the following tasks:
a. Assign the sum of x and y to z, and increment the value of x by 1 after the calculation. Use only
one statment.
b. Test whether the value of the variable count is greater than 10. If it is, then print “Count is
greater than ten.”.
c. Decrement the variable x by 1, then subtract it from the variable total. Use only one statement.
d. Calculate the remainder after q is divided by divisor, and assign the result to q. Write this
statment in two different ways.
e. Declare variables sum and x.
f. Assign 1 to variable x.
g. Assign 0 to variable sum.
h. Add variable x to variable sum, and assign the result to variable sum. Print “The sum is: “,
followed by the value of variable sum.
18) Write a program that calculates an average of miles per gallon for a vehicle over the history of
miles/gallons factor. The steps are the following:
a. Input number of full tanks to average.
b. Input the gallons of fuel filled for number x
c. Input the miles driven for number x
d. Repeat entry of gallons and miles until the number of tanks is entered.
e. Print the average miles per gallon for each tankful and print an average at the bottom.
19) Write a program that calculates whether a customer has exceeded the credit limit of an account. To do
this:
a. Obtain account number, balance previous, total charges, total payments/credits, and credit
limit.
b. Calculate current debt balance
c. Compare that the debt is < credit limit, if so print leftover credit, if not print credit exceeded
20) Write a program that computes the commission and total payment of sales of an employee. This
program will:
a. Ask for sale item amount.
b. Repeat until data is done being entered.
c. Calculate the percentage of commission based on total sales.
3
d. Add base pay.
e. Print items and total amount.
21) Create a program that calculates the gross pay of an employee, taking into account overtime
compensation. To do this:
a. Take in employee name.
b. Take in employee rate pay.
c. Take in employee hours worked that week.
d. If hours over 40, then the hours minus 40 should have a rate of time and a half added to the
total 40 * rate.
e. Print results.
f. Repeat until all employees are added.