Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Zayed University

THE COLLEGE OF INFORMATION


TECHNOLOGY

CIT 225: Introduction to Programming and Problem Solving


Java Script Assignment

Part 1: If Statements, Loops and Pop up Messages

Write a script that asks the user to enter a number through a prompt dialog. You have to
test the number if it is even or odd number and display the result in an alert dialog. Ask
the user if he wants to continue in entering the numbers. If yes then you have to repeat
the above steps, if no then the script ends.

Part 2: If Statements & Functions

Write a script that contains a function getStatus() that you can pass a grade as a parameter
and have it display based on the following:
A is a grade of 90 or greater
B is a grade of 80 or greater, but less than 90
C is a grade of 70 or greater, but less than 80
F is any grade below 70

Demonstrate the function by printing out the grade for five students. One example of one
student could be:
document.write("Mary - ") + getStatus(94) + document.write("<BR>")

Part 3: If Statements & Events Handlers

Place a single button on a page that could be used as an ON/OFF switch. Design this
button so that the button is labeled "ON". When you click on the button its label should
change to "OFF". Clicking on it again should change it back to "ON" and so on.

Part 4: Loops

Write a script to print the numbers 1 through 20. Your results should be printed on 4 lines
with 5 numbers on each line. Be sure to put a space between the numbers that are on the
line. This will require a loop inside of a loop. I recommend that you get one loop working
and then add the second.

You might also like