Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

The Winning Ticket and Deadline Constraints

1 answer below »
COP3503 Computer Science 2
Dr. Andrew Steinberg
Summer 2022
Programming Assignment 1
The Winning Ticket and Deadline Constraints
Due: 6/5/2022 at 11:59pm
Objective: Students will apply their basic knowledge of Java in this programming assignment.
Problem Scenario: You saw on the news that the Super-Duper Lotto Company is doing a once
in a lifetime lotto draw of 1 billion dollars. You decided to take the biggest risk and invest in
uying XXXXXXXXXXunique lotto tickets. Later that evening, you watch the news to witness the lotto
draw. The numbers are called one-by-one and you find out that you are the lucky winner. Now
that you are the lucky winner, the company has a set deadline for the winner to present the ticket
in order to claim the prize. If the recipient doesn’t present the winning ticket by the deadline, the
ecipient forfeits the money prize. The recipient will now have to go through the entire set of
tickets purchased to find the winner. The recipient knows that the tickets are sorted when they
were purchased.
Assignment Description: In this programming assignment, you will need to derive two
solutions. One solution must run in ?(?) time and the other must run in ?(log ?) time where n is
the number of tickets. This programming assignment must be completed in the Java
programming language. Any other language used will result in score of 0 on the assignment.
For this assignment, you must follow these requirements.
1. You cannot use any predefined data structure class (such as A
ayList). Using other
predefined data structure classes will result in point deductions.
2. You must use the A
ay as the data structure to store the Lottery class objects. Any
other data structure used will result in point deductions.
3. Each ticket contains 6 digits XXXXXXXXXXThe digits can be repeated in the tickets. Examples
include 003221, 529495, etc…
4. You will create a class called Lottery with the following required defined methods and
attributes:
a. An attribute of type String called ticket which holds the digit values. Make it
private as that is good practice!
. Two Constructors
i. One default constructor that sets ticket to an empty string.
ii. One overloaded that takes a Random class reference.
c. GenerateRandomWinner
i. Method that takes a Random class object reference as a parameter.
COP3503 Computer Science 2
Dr. Andrew Steinberg
Summer 2022
ii. This method generates a random digits for the ticket and returns it. The
type is String.
d. GenerateSelectWinner
i. Method that takes a Random class object reference as a parameter and the
max possible index of the a
ay in a given scenario.
ii. Method returns an index of the a
ay of a winning ticket. (this is to test
your two algorithms to see if it actually works by guaranteeing a winning
ticket is found).
e. Solution1
i. One of the solutions that finds the winning ticket.
ii. This method should run O(n).
iii. Returns a Boolean if found or not.
f. Soluton2
i. One of the solutions that finds the winning ticket.
ii. This method should run O(lgn).
iii. Returns a Boolean if found or not.
g. You will need to create an accessor method to retrieve the ticket attribute.
h. You will need to create a sort method to sort the tickets.
i. You cannot use any built in sort method.
j. You may create any additional methods that will assist in this programming
assignment as long as they are not called in the runner file directly.
A runner file (LotteryRunner.java) has been provided for you to show you how the methods
are called along with 5 test cases based on the size of the input a
ay. Note, these test cases ran
on the Eustis environment (if you run on your local system, the pseudorandom generator will
produce different numbers which can potentially leading to a test case failing). One thing you
will have to make sure is that your two algorithms satisfied the running time restrictions. These
test cases ensure that your solution is co
ect in producing the desired output. They do not test
your run time.
What to submit: Submit a file called Lottery.java to webcourses. You are not required to
submit the runner file as that will be provided for the graders to test your code. Please make sure
the runner file provided works for your code. Any name changes may cause your program not to
work when graded, which will result in a lower score on the assignment and would not be
changed.
Important Note for running Eustis: Many of you are probably using IDEs like Netbeans and
Eclipse to build your Java Solutions. Please note that some of these IDEs will automatically
place your Java file in some sort of package. Please make sure your Java file is not defined in
some package as this can result package private e
ors. Any such e
or that occurs during the
grading will not be fixed and points will be deducted as such in accordance with the respective
categories in the ru
ic.

Beginning Test Cases
*********************************
TEST 1
TESTING When A
ay holds 1000 Tickets
Testing Solution 1
Solution 1 Test 1 Passed!
Testing Solution 2
Solution 2 Test 1 Passed!
*********************************
TEST 2
TESTING When A
ay holds 2000 Tickets
Testing Solution 1
Solution 1 Test 2 Passed!
Testing Solution 2
Solution 2 Test 2 Passed!
*********************************
TEST 3
TESTING When A
ay holds 5000 Tickets
Testing Solution 1
Solution 1 Test 3 Passed!
Testing Solution 2
Solution 2 Test 3 Passed!
*********************************
TEST 4
TESTING When A
ay holds 9000 Tickets
Testing Solution 1
Solution 1 Test 4 Passed!
Testing Solution 2
Solution 2 Test 4 Passed!
*********************************
TEST 5
TESTING When A
ay holds XXXXXXXXXXTickets
Testing Solution 1
Solution 1 Test 5 Passed!
Testing Solution 2
Solution 2 Test 5 Passed!
Answered 4 days After May 26, 2022

Solution

Kshitij answered on May 31 2022
97 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here