WEB222 Assignment 1 – Sections A, B, C solved

$24.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (4 votes)

Objective: Practice JavaScript basic syntax, built‐in functions, and user defined functions. Specification: Write a JavaScript program assignment01.js to perform the following tasks. No validation is required for user input – assume that the user will enter valid information. Open a Firefox Scratchpad. Create comment line(s) for each of the Tasks using block comments, indicating the start point of each Task. e.g. /***************************** * Task 1 *****************************/ To run part (e.g. the code for Task 1) of your JavaScript code in Scratchpad, you need to highlight that part of code and click on the Run button. Variable values will be kept in memory after a piece of code is run. So (usually) you need to initialize variables to ensure the part of code can repeatedly give the same result.
Task 1: Student Info (use your information) a) Store the following information in variables: student name, number of courses (currently taking), program, having a part‐time job (true/false). b) Output your student info to the browser console as: “My name is ??? and I’m in ??? program. I’m taking ??? course in this semester.” (NOTE: The “???”s should be replaced with variable or calculated values ‐ this also applies to all other outputs containing ??? listed in this assignment). c) Store the string “have” or “don’t have” into a variable based on the value of the variable storing whether or not you have a part‐time job (true/false). d) Output your updated student info to the console as: “My name is ??? and I’m in ??? program. I’m taking ??? course in this semester and I ??? a part‐time job now.”
Task 2: Birth and graduate year a) Store the current year in a variable. b) Prompt to user “Please enter your age:” and store the input value in a variable. c) Output the birth year to the console as: “You were born in the year of ???.” d) Prompt to user “Enter the number of years you expect to study in the college:” and store the input value in a variable. e) Output the graduate year to the console as: “You will graduate from Seneca college in the year of ???.” Note: you may need to do some research on JS prompt() method to find out how it works.
Task 3: Celsius and Fahrenheit temperatures a) Store a Celsius temperature in a variable. b) Convert it to Fahrenheit and output: “???°C is ???°F”. c) Store a Fahrenheit temperature into a variable. d) Convert it to Celsius and output: “???°F is ???°C.” Note: visit www.manuelsweb.com/temp.htm for temperature conversion formula.
Task 4: Even and odd numbers a) Write a for loop that will iterate from 0 to 10. For each iteration, your code should check if the current number is even or odd, and output that information to the browser console (e.g. “5 is odd”).
Task 5: Larger or largest number a) Write a function named largerNum using the declaration approach, the function: takes 2 arguments, both numbers, returns the larger (greater) one of the 2 numbers. b) Write a function named greaterNum using the expression approach, the function: takes 2 arguments, both numbers, returns the greater (larger) one of the 2 numbers. c) Call these functions twice with different number parameters, and log the output to the web console with descriptive outputs each time (e.g. “The larger number of 5 and 12 is 12.”).
Task 6: Evaluator a) Write a function named Evaluator using the declaration approach, the function: takes unknown number of arguments which are all number scores, returns true if the average of these number scores is greater than or equal to 50. Otherwise return false. b) Call this function 3 times with different number parameters, and log the output to the web console with descriptive outputs each time (e.g. “Average grater than or equal to 50: false”);
Task 7: Grader a) Write a function named Grader using the expression approach, the function: takes a single argument which is a number score, returns a grade for the score ‐ “A”, “B”, “C”, “D”, or “F”. (refer to course outline for grading memo) b) Call these functions 3 times with different number score, and log the output to the web console with descriptive outputs each time.
Task 8: ShowMultiples a) Write a function called showMultiples using the declaration approach, the function: Takes 2 numeric arguments (num, numMultiples) – assume the user is entering valid (positive) whole numbers Outputs all of the multiples of the num argument from 1 to numMultiples: for example:
if num = 5 and numMultiples = 4, the function would output: 5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 b) Call this function 3 times with different number parameters, and log the output to the web console with descriptive outputs each time.
Lab Submission: Save your file as assignment01.js. add the following comment declaration with your info at the top of your code (failure to do so will result in zero mark for the entire assignment): /********************************************************************************* * WEB222 – Assignment 01 * I declare that this assignment is my own work in accordance with Seneca Academic Policy. No part of * this assignment has been copied manually or electronically from any other source (including web sites) * or distributed to other students. * * Name: ______________________ Student ID: ______________ Date: ________________ * ********************************************************************************/ Submit your assignment01.js to the Blackboard / My.Seneca (zip and upload in case my.seneca does not allow uploading plain js file. In the worst case, i.e., you do not know how to zip, you may change the js extension to txt, but you must learn how to zip files for later assignments) Important Note: NO LATE SUBMISSIONS for assignments. Late submissions will not be accepted and will receive a grade of zero (0). After the end (11:00PM) of the due date/time, the assignment submission link on the Blackboard will no longer be available. Allow enough time to upload. Do not wait for the last moment since there are transmission time/queuing delay/processing time etc. from your machine to the blackboard server.