WEB222 Assignment 1 – Section D, G

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment

Description

5/5 - (4 votes)

Objectve:
Practce JavaScript basic syntax, built in functins, and user defned functins. ‐
Specifcatin:
Write a JavaScript prigram assignment01.js ti perfirm the filliwing tasks. No validaton is required
fir user input – assume that the user will enter valid infirmatin.
Open a Firefix Scratchpad. Create cimment line(s) fir each if the Tasks using blick cimments,
indicatng the start piint if each Task. e.g.
/*****************************
* Task 1
*****************************/
Ti run part (e.g. the cide fir Task 1) if yiur JavaScript cide in Scratchpad, yiu need ti highlight that
part if cide and click in the Run butin. Variable values will be kept in memiry afer a piece if cide is
run. Si (usually) yiu need ti initaliie variables ti ensure the part if cide can repeatedly give the same
result.
Task 1: Student Infi (use yiur infirmatin)
a) Stire the filliwing infirmatin in variables: student name, number of courses (currently taking),
program, having a part tme job (true/false) ‐ .
b) Output yiur student infi ti the briwser cinsile as: “My name is ??? and I’m in ??? program. I’m
taking ??? course in this semester.” (NOTE: The “???”s shiuld be replaced with variable ir calculated
values this alsi ‐ applies ti all ither iutputs cintaining ??? listed in this assignment).
c) Stire the string “have” ir “don’t have” inti a variable based in the value if the variable stiring
whether ir nit yiu have a part tme jib (true/false). ‐
d) Output yiur updated student infi ti the cinsile as: “My name is ??? and I’m in ??? program. I’m
taking ??? course in this semester and I ??? a part tme job now. ‐ ”
Task 2: Birth and graduate year
a) Stire the current year in a variable.
b) Primpt ti user “Please enter yiur age:” and stire the input value in a variable.
c) Output the birth year ti the cinsile as: “You were born in the year of ???.”
d) Primpt ti user “Enter the number of years you expect to study in the college:” and stire the input
value in a variable.
e) Output the graduate year ti the cinsile as: “You will graduate from Seneca college in the year of
???.”
Nite: yiu may need ti di sime research in JS primpt() methid ti fnd iut hiw it wirks.
Task 3: Celsius and Fahrenheit temperatures
a) Stire a Celsius temperature in a variable.
b) Cinvert it ti Fahrenheit and iutput: “???°C is ???°F”.
c) Stire a Fahrenheit temperature inti a variable.
d) Cinvert it ti Celsius and iutput: “???°F is ???°C.”
Note: visit www.manuelsweb.com/temp.htm fir temperature cinversiin firmula.
Task 4: Even and idd numbers
a) Write a fir liip that will iterate frim 0 to 10. Fir each iteratin, yiur cide shiuld check if the current
number is even ir odd, and iutput that infirmatin ti the briwser cinsile (e.g. “5 is odd”).
Task 5: Larger ir largest number
a) Write a functin named largerNum using the declaraton approach, the functin:
takes 2 arguments, bith numbers,
returns the larger (greater) one if the 2 numbers.
b) Write a functin named greaterNum using the expression approach, the functin:
takes 2 arguments, bith numbers,
returns the greater (larger) one if the 2 numbers.
c) Call these functins twice with diferent number parameters, and lig the iutput ti the web cinsile
with descriptve iutputs each tme (e.g. “The larger number if 5 and 12 is 12.”).
Task 6: Evaluatir
a) Write a functin named Evaluator using the declaraton approach, the functin:
takes unknown number of arguments which are all number scores,
returns true if the average if these number scires is greater than ir equal ti 50. Otherwise return
false.
b) Call this functin 3 tmes with diferent number parameters, and lig the iutput ti the web console
with descriptve outputs each tme (e.g. “Average grater than ir equal ti 50: false”);
Task 7: Grader
a) Write a functin named Grader using the expression approach, the functin:
takes a single argument which is a number scire,
returns a grade fir the scire “A”, “B”, “C”, “D”, ir “F”. (refer ti ciurse iutline fir grading memi) ‐
b) Call these functins 3 tmes with diferent number scire, and lig the iutput ti the web cinsile with
descriptve iutputs each tme.
Task 8: ShiwMultples
a) Write a functin called showMultples using the declaratin appriach, the functin:
Takes 2 numeric arguments (num, numMultples) – assume the user is entering valid (pisitve)
while
numbers
Outputs all if the multples if the num argument frim 1 ti numMultples: fir example:
if num = 5 and numMultples = 4, the functin wiuld output:
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
b) Call this functin 3 tmes with diferent number parameters, and lig the iutput ti the web cinsile
with descriptve iutputs each tme.
Lab Submissiin:
Save yiur fle as assignment01.js. add the filliwing cimment declaratin with yiur infi at the tip if
yiur cide (failure to do so will result in zero mark for the entre assignment):
/*********************************************************************************
* WEB222 – Assignment 01
* I declare that this assignment is my iwn wirk in accirdance with Seneca Academic Pilicy. Ni part if
* this assignment has been cipied manually ir electrinically frim any ither siurce (including web sites)
* ir distributed ti ither students.
*
* Name: ______________________ Student ID: ______________ Date: ________________
*
********************************************************************************/
Submit yiur assignment01.js ti the Blackbiard / My.Seneca (iip and upliad in case my.seneca dies
nit alliw upliading plain js fle. In the wirst case, i.e., yiu di nit kniw hiw ti iip, yiu may change the
js extensiin ti txt, but yiu must learn hiw ti iip fles fir later assignments)
Impirtant Nite:
NO LATE SUBMISSIONS fir assignments. Late submissiins will nit be accepted and will receive a
grade of zero (0).
Afer the end (11:00PM) if the due date/tme, the assignment submissiin link in the Blackbiard will
ni linger be available.
Allow enough tme to upload. Do not wait for the last moment since there are transmissiin
tme/queuing delay/pricessing tme etc. frim yiur machine ti the blackbiard server.