Create the html markup and javascript code

Assignment Help Web Project
Reference no: EM132276290

Assignment - Decisions, Repetitions, Built In Objects

ASSIGNMENT OVERVIEW:

Your task in this assignment is to create the HTML markup and JavaScript code that simulates play of the 649 lottery.

In the 649 lottery, a player plays a ticket consisting of 6 different numbers from 1 to 49 inclusive. Another ticket of 6 numbers is also drawn (randomly) from the same set of 1 to 49 inclusive. Prizes are awarded based on the number of matches between the player's ticket and the one drawn - the greater the number of matches the higher the prize.

In the version you are coding a player can choose their numbers by using 49 checkboxes OR they can let the computer randomly ‘quick pick' the 6 numbers in their ticket.

The JavaScript code required will make significant use of:
• decision statements (if and/or switch)
• repetition statements (for and/or while)
• built in objects (properties and/or methods of Math, Date, Array) The HTML elements needed are:
• 2 radio buttons (input type="radio") to ask for a ‘quick pick' (YES, NO)
• 49 check boxes (input type="checkbox") to manually pick the 6 numbers
• a Play Lotto button to play the lottery
• a div to display or output the results

Clicking the button is the only event that calls JavaScript code i.e. it is the only element with an event handler.

Assuming that the player has correctly made their selection, clicking the Play Lotto button will cause the following to display in the div:
1. the date and time of the draw, suitably formatted
2. the six numbers drawn (as a single row table), sorted in ascending order
3. whether the played opted for a quick pick or manual selection
4. the six numbers played (as a single row table), also in ascending order
5. matching numbers in the player's ticket highlighted
6. a message showing the number of matches and description (if any)

The following screen capture shows these components of the display:

Your code will follow these client side programming best practices:
1. all JavaScript code is loaded from an external file
2. all event handler functions are set-up in JavaScript not in the HTML
i.e. no onclick, onchange, ... HTML attributes
3. all of the JavaScript code is inside the event handler for the onload event on the window object
4. no globals - all variables are declared inside the onload handler
5. all DOM elements are referenced once and stored using const
6. use const and let to declare variables, not var
7. the event handler is attached using addEventListener()
8. strict comparison operators are used e.g. === instead of ==

In order to complete this assignment some or all of the code constructs in the table below will be required.

CODING INSTRUCTIONS:

STEP 1 - Write the HTML markup
This assignment requires the following HTML elements:
• 2 radio buttons (input type="radio") to specify a ‘quick pick' (YES, NO)
• 49 check boxes (input type="checkbox") to manually pick the 6 numbers
• a Play Lotto button to play the lottery
• a div to display the results

Create an .html file and add to it these required elements and content so that it has the required content and structure, then validate your HTML.

NOTE: You are not required to apply any CSS styles i.e. you do not have to style the elements as shown in the screen capture above. But you are in a design program so why would you not want to make it look good?

STEP 2 - Code the JavaScript
1. Place all of your code inside the window.onload event handler function. Use the addEventListener() DOM method to register a click event handler function for the PLAY LOTTO button. Note that the JavaScript code to play the game is only called by clicking the PLAY LOTTO button.

2. The main logic flow in the PLAY LOTTO handler is controlled by the option chosen in the radio button. Use alert() to display an error messages if the player has opted to manually select their numbers (NO is selected as the radio button), but has chosen too few (< 6) or too many (> 6) numbers.

Do not reset the checkboxes if too few or too many numbers are chosen.

3. If the player has opted to pick their own numbers and has checked exactly 6 boxes, then store the 6 values checked in an array.

4. If the player has opted for a ‘quick pick', then randomly pick 6 different numbers from 1 through 49 and store them in an array. Code a loop that runs 6 times to do this. While there are several different ways to code this all of the approaches will rely on the Math.random() method. The challenge is ensuring the numbers selected are all different.

5. Repeat the procedure from the previous step to pick another set of 6 different numbers from 1 to 49 for the numbers drawn and store then in another array.

6. Sort the two arrays containing the picks in increasing numeric order by using the sort() array method with the parameter function(x,y) { return x - y;}.

7. Start the display of the results by using the Date object and its methods to display a time stamp of when the play occurred. The format of this time stamp must match the one in the screen captures exactly. In particular the day, month, and year must be displayed in full. As well, the minutes and seconds are always displayed using 2 digits. Note that all of the results can be concatenated into one string and written to the div using innerHTML.

8. Continue with the results by displaying the numbers drawn as a table with one row and six cells, each cell containing one of the six numbers in the ticket. Use a loop to create a string with the necessary table markup (table, tr, td elements) using the numbers drawn as the cell content.

9. Announce the player's numbers by indicating whether they opted for a quick pick or selected them using the checkboxes.

10. Display the player's numbers as in step #8.

11. Determine how many of the player's numbers match those in the draw. Display a message indicating the number of matches. The following screen capture shows these 5 components of the display:

12. By using CSS properties highlight the numbers in the player's ticket that match a number in the drawn ticket. See the screen captures that follow for examples. Note that the description of the number of matches changes in the text following the display of the player's ticket.

Attachment:- Assignment.rar

Verified Expert

The play lottery program developed using Javascript and HTML. Players randomly choose the six different numbers from 1 to 49. Generate random numbers for matching the players picked numbers. Whether the numbers are matched the message will be displayed. The message depends on the matched numbers. The user picked numbers are less than or greater than six the error message will be displayed.

Reference no: EM132276290

Questions Cloud

How do you reach communities about breaking disease chain : When it comes to a healthy community, education is key. How do you reach communities about breaking the disease chain when those communities may be difficult
What are the ethical issues associated to this case : What are some of the longterm benefits and harms of rates and fees associated to credit cards? Which legal requirements are driving the behaviors in this case?
What business are we in : For a strategic change project, analyze and evaluate the relevance of answering the following question;What business are we in?
Discuss the williams act and the implications : Discuss the Williams Act and the implications it places on mergers and acquisitions.
Create the html markup and javascript code : CWMD2601 – Scripting for Design - Durham College - Create the HTML markup and JavaScript code that simulates play of the 649 lottery
Who are the participants and how will they be recruited : Who are the (expected) participants? How many? Are they part of a special population? (In-patient, residential, part of an alternative school, victims).
Discuss the intelligence theories of sternberg : Discuss the intelligence theories of Sternberg, Gardner, and Coleman (emotional intelligence). Which one is most agreeable, and why? Using the preferred theory.
How might health care teams achieve therapeutic goals : How might health care teams achieve therapeutic goals for individual clients? What factors might lead to the failure of the CC/IC delivery model?
Summarize the reading that you selected : Summarize the reading that you selected. Based on your reading, identify one or more issues that you have identified within the correctional systems.

Reviews

len2276290

4/5/2019 11:32:54 PM

REMEMBER, TO AVOID LOSING MARKS UNNECESSARILY … 1. Only use JavaScript and DOM capabilities that have been covered to this point in the course to complete the assignment. Do not use any JavaScript libraries or frameworks such as jQuery. 2. Always test your program with a variety of input values to ensure that it is working correctly i.e. has no syntax errors and produces the expected results. 3. Add opening comments to identify yourself as the programmer and explain the purpose of your program. Add comments to document your code. 4. View your source in Firefox before submitting to make sure that the indentation and white space are correct, and that horizontal scrolling is not required. 5. Load all JavaScript code from one external file and submit all of the files used in the solution as one zipped folder. 6. As the very last thing you do before submitting, test your program one more time and check the Console to ensure it is error free.

len2276290

4/5/2019 11:32:39 PM

REFERENCES Lecture notes for TOPIC 2 to TOPIC 8 JavaScript (6th edition), Vodnik and Gosselin Chapters 1, 2, 3, 4, 5, 7 Code samples in lecture notes SUBMITTING 1. Upload your work using the correct drop box in DC Connect. Only work submitted through DC Connect will be marked. 2. Upload all required files (i.e. .html, .css, and .js) as one zipped folder.

len2276290

4/5/2019 11:32:22 PM

ASSIGNED At date and time shown in DC Connect. DUE At date and time shown in DC Connect. There is a 25% penalty for late assignments. Refer to the course outline for details. DEADLINE Thursday, April 18, 11:59PM. No assignments accepted after the deadline. WEIGHTING Counts as 10% of your final mark. MARKING Marked out of 100 (80 for function, 10 for style, and 10 for documentation). Full marks given only if your solution: ? meets all of the requirements ? has no runtime errors ? follows all of the course coding conventions ? uses only the JavaScript and DOM capabilities covered to this point in the course i.e. no JS libraries ? uses external JavaScript and is submitted as a single zipped folder with all required files

Write a Review

Web Project Questions & Answers

  Create web page from number one with silver background color

Create the Web page from number 1 with silver background color set by a Cascading Style Sheet (.css). Create the Web page from number 1 with silver background color and Comic Sans MS font set by a Cascading Style Sheet (.css).

  Describing the design for a small web site

Develop a 5-6 page Word document that describes the design for a small Web site that meets the following specifications.

  Create web page that displays result of rolled dice randomly

Create a web page that displays result of a rolled dice randomly. Create a basic calculator that works and uses operators (+, -, /, and *) to make calculations.

  Create a web page and an external style sheet

You want to create a Web page and an external style sheet that lists your piano practice and volunteer schedule - Create a Web page and an external style sheet.

  Attributes of effective powerpoint presentation

Are there any sites that details the attributes of an effective PowerPoint presentation. Also what in your opinion would be one or two best practices that I should think about when preparing the PowerPoint presentation?

  Prepare a report about model-view-controller

Prepare a report about Model-View-Controller (MVC) pattern roles in the Distributed Web Application. Compare and Contrast the Java Script based Client Side Rendering Framework of your choice and Java Server Faces (JSF) by providing suitable diagra..

  Develop a visual rendering depicting your design

Develop a visual rendering depicting your design through the use of Microsoft Visio or its open source alternative, Dia. Note: The graphically depicted solution is not included in the required page length.

  Describe prominent signs that a database attack has occurred

Describe the most prominent signs that a database attack has occurred. Suggest the main steps that one would take to recover from such an attack.

  Create a home page with navigation bar to the three pages

Create a home page with navigation bar to the three pages with images listed below and a Cascading Style Sheet (.css) for bisque color and Arial text.

  Do you think your company has a right to do this

The sales team of Sand Shell Inc. consists of six persons who use the e-mail service extensively for their communication with clients. Bob, one of the salespeople, is going on a vacation.

  Complete the rock paper scissor game

Complete the rock paper scissor game Complete function to make it functionally

  Identify the web pages that you would secure using ssl.

Identify the web pages that you would secure using SSL. State reasons why the web pages you have identified should be secure.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd