Question: Write a Program in Java using JOptionPane and try to test the data after the codes are written. City Bucks Your City lottery ticket consists

Write a Program in Java using JOptionPane and try to test the data after the codes are written.

City Bucks

Your City 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!