Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Program in Java. Town Bucks Your Town lottery ticket consists of your 6 lucky numbers. The winning combination consists of 6 unique numbers

Write a Program in Java.

Town Bucks

Your Town lottery ticket consists of your 6 lucky numbers. The winning combination consists of 6 unique numbers (between 1 and 40). The prizes are as follows:

Amount Category

$10 exactly one match

$25 exactly two matches

$25 per match 3, 4 or 5 matches

$50 per match 3, 4 or 5 consecutive matches

$1000 6 matches in any order

$10,000 6 matches in exact order

Each ticket claims the highest prize that it can. In addition, if there are fewer than 6 matches and if the sum of the numbers on the ticket equals the sum of the winning numbers, then the prize value is doubled.

For example, suppose that your numbers are 1, 9, 8, 4, 2 and 3 (note that all numbers are unique), and the winning numbers are 8, 7, 2, 5, 4, 1 (again, note that all numbers are unique). To figure out your prize value consider each of your numbers in turn: the 1 matches; the 9 does not match; the 8, 4, and 2 matches (consecutively); and the 3 does not match. The four matches are worth $100 (each match is worth $25 by the third rule), while the three consecutive matches are worth $150 (each match is worth $50 by the fourth rule). Therefore, you claim a prize of $150. But wait! Because the sum of your numbers equals the sum of the winning numbers, your prize value is doubled to be worth $300!!

Input: Your ticket (6 numbers) followed by four winning combinations (each consists of 6 numbers).

Sample Input: 5, 2, 12, 22, 16, 38

8, 33, 19, 12, 40, 7

9, 7, 12, 22, 16, 40

1, 17, 19, 35, 25, 30

5, 2, 13, 21, 15, 39

Output: The value of your ticket won for each of the winning combinations.

Sample Output (to above data):

10

150

0

50

This program is to be well-written (modular using functions and passing parameters) and well-documented both internally and externally.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions