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

  Evaluating an ecommerce website

Create a check list that contains key point for evaluating an ecommerce website - Write a short, reflective report about website

  Gpc and runtime magic quotes

Create a script that lets you know whether Zeus or Helios has the GPC and Runtime Magic Quotes turned on or off. The output should have appropriate labels that define what output signified and should display 'ON' or 'OFF' depending on the setting.

  Creating functions through conditional operator

Use the conditional operator and the cal_days_in_month function, determine the number of days in the current month and output to browser whether it is normal month or a leap month.

  Web development projects with database

Since the vast majority of web-development projects involve a database, do you think that computational activities should be performed there, or do you think they belong in the XML page or stylesheet?

  Comparing shelf software packages

Required assistance with comparing and contrasting two main off the shelf software packages that could be implemented in an organization.

  Web based scams

Web phishing, pharming and vishing are popular web based scams. Talk about currently used tools and recommended measures to defeat this kind of attacks efficiently?

  Explanation of contextual links

The most powerful hypertext capabilities is the the contextual link. Wikipedia . com is a great example of a site that utilizes contextual links.

  How architectural and protocol changes occur

Discuss how architectural and protocol changes happen, the administrative organization that oversees the technical development of the Internet,

  Traditional approaches for training professionals

Webinars and other web conferencing techniques have proved most beneficial for the provision of affordable quality corporate training.

  Internet for business

Discuss how can a business use the Internet and give at least three examples with web links demonstrating your answer.

  It influences the behavior of organizations

Information technology influences the behavior of organizations. Name one effect of Information technology implementation and long-term usage you suppose having a positive contribution and one having a negative consequence.

  Importance of a guided navigation system

Explain the use and importance of a guided navigation system and shopping cart for a website designed for e-commerce and business purpose.

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