PART A Implement a simulation of a popular game known as the lotto. The program should generate 6 random numbers between 1 and 45 (inclusive). These 6 numbers represent the winning combination of the...








PART A


Implement a simulation of a popular game known as the lotto. The program should generate 6 random numbers between 1 and 45 (inclusive). These 6 numbers represent the winning combination of the Jackpot. A 7th
random number should then be generated as part of the draw and this number is what is known as the bonus number. None of the 7 numbers generated in the draw should be repeated.



Assume that a lotto ticket contains 1 line of 6 random numbers between 1 and 45 (inclusive). No number can be repeated in the line.



Simulate the generation of 50,000 lotto tickets.



The program should keep a count of the number of winners (winning line combinations) for each of the following categories:



Jackpot – all numbers in one line match the winning combination


Match 5 + Bonus – five matching numbers and the bonus number


Match 5 – five matching numbers


Match 4 + Bonus – four matching numbers and the bonus number


Match 4 – four matching numbers


Match 3 + Bonus – three matching numbers and the bonus number


Match 3 – three matching numbers



A single ticket can only win in one prize category, which would be the highest prize category it matches.



Assume the total prize fund available is €1,000,000, with the available allocation for each of the prize categories as follows:



Jackpot – 46.15% of prize fund


Match 5 + Bonus – 2.36% of prize fund


Match 5 – 5.38% of prize fund


Match 4 + Bonus – 1.35% of prize fund


Match 4 – 8.3% of prize fund


Match 3 + Bonus – 5.53% of prize fund


Match 3 – 13.28% of prize fund



Your program should display the number of winners for each category and calculate and display the prize money awarded to a winning ticket in each category.



Sample screen output:










Lotto results:



Match Winners Prize


Jackpot Winner 1 461,500.00


Match 5 + Bonus 0 0.00


Match 5 1 53,800.00


Match 4 + Bonus 1 13,500.00


Match 4 61 1,360.66


Match 3 + Bonus 83 666.27


Match 3 1038 127.94





PART B


Create a two minute Screen Cast giving a detailed explanation of the workings of the Java code submitted for question 2 PART A.



Purpose: Demonstrate understanding of the Java programming language and learning outcomes relating to the assignment two study period.



Using the Screencast-o-matic tool available at https://screencast-o-matic.com/ (or any screen-casting tool you may own) create a screencast, maximum two minutes in length.



In this screencast, demonstrate your understanding of the Java programming language in relation to your answer for PART A.



A perfect studio recording is not expected here, if you make a mistake, acknowledge it and carry on.



If an answer is not submitted for PART B, zero marks will be awarded for question 2.


(40 marks)









Question 3



Extend the answer to question 2 to print the Lotto results in CSV (comma-separated-values) format to a file. Save this answer in its own separate .java file.



Please note that the file should contain only eight lines of CSV data. The file name should be of the format YYYYMMDD.dat where


o YYYYMMDD is today’s date in year month day format


o .dat is the filename extension.


o Example filename: 20171212.dat, if run on 12/12/2017.



*Please note that it is acceptable for question 3 to be written independently of question 2, by writing sample Lotto results to a file such as the following sample file contents (as opposed to the output from question 2).



Sample File Contents:











Match,Winners,Prize


Jackpot Winner,1,461,500.00


Match 5 + Bonus,0,0.00


Match 5,1,53,800.00


Match 4 + Bonus, 1,13,500.00


Match 4, 61,1,360.66


Match 3 + Bonus,83,666.27


Match 3,1038,127.94





(20 Marks)









Question 4



Write a program that reads from a file of lotto results (such as the sample file contents given in question 3). The program should display the total number of winners (regardless of category), the total winnings, and the leftover prize-money in the pot for the next draw. Each output should be separated by the | symbol.



*Please note that it is acceptable for question 4 to be written independently of questions 2 and 3, by providing sample Lotto results in a file in the format requested for question 3 and then reading in from that file for this question and showing the results as requested.










Sample screen output:










Total Winners|Total Winnings|Leftover


1185|530954.87|469045.13


Jan 16, 2020
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here