I created this program using the Java-oriented programming application known as Eclipse for a lottery system, however it's not giving me the output I want. The output should look something like this:
Trial Sum Count of Occurrence
3 150
4 170
5 1100
6 1460
...
83 240
84 90
Any help with the following program would be appreciated
/* Simulate a Pick 3 lottery system and conduct 100,000 independent lottery trials* reporting out aggregate statistical data based on your results. The lottery pool consists of numbers 0-29* (with no duplicates occurring in any given trial). You must use ArrayList to solve this problem.*/
importjava.util.ArrayList;
importjava.util.Random;
public class Lottery
{
Random rando;
ArrayList pool;
ArrayList storage;
ArrayList countholder;
ArrayList neostorage;
publicLottery()
{
neostorage= newArrayList<>();
countholder= newArrayList<>();
storage= newArrayList<>();
pool= newArrayList<>();
for(int i=0; i<30; i++)
{
pool.add(i);
}
rando= newRandom();
}
public void run Lottery()
{
int counter= 0;
int sum= 0;
boolean same= true;
for(int i=0; i<1000; i++)
{
int store1= rando.nextInt(pool.size()-1);
int store2= rando.nextInt(pool.size()-1);
int store3= rando.nextInt(pool.size()-1);
while(same)
{
if(store1== store2|| store2== store3|| store1== store3)
{
store1= rando.nextInt(pool.size()-1);
store2= rando.nextInt(pool.size()-1);
store3= rando.nextInt(pool.size()-1);
}
else
{
same= false;
}
}
same=true;
while(same)
{
if(sum<3 && sum>84)
{
store1= rando.nextInt(pool.size()-1);
store2= rando.nextInt(pool.size()-1);
store3= rando.nextInt(pool.size()-1);
}
else
{
same= false;
}
}
sum= store1+store2+store3;
storage.add(sum);
for(int k= 0; k
{
counter= 1;for(int j= k; j
{
if(storage.get(j) == storage.get(k))
{
counter++;
}
}
countholder.add(counter);
neostorage.add(storage.get(k));
}
}
System.out.println("Trial Sum Count of Occurences ");
for(int i= 0; i
{
System.out.println(neostorage.get(i) + " "+ countholder.get(i));
}
}
public static void main (String[] args)
{
Lottery lot= newLottery();
lot.runLottery();
}
}

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
public class Lottery {
private Random rando;
private int maxElement;
private int numExperiments;
public Lottery() {
maxElement = 29;
numExperiments = 100000;
rando = new Random();
}
public void runLottery() {
boolean same = true;
HashMap<Integer, Integer> sumCounts = new HashMap<>();
for (int i = 0; i < numExperiments; i++) {
same = true;
int store1=0, store2=0, store3=0;
while (same) {
if (store1 == store2 || store2 == store3 || store1 == store3) {
store1 = rando.nextInt(maxElement + 1);
store2 = rando.nextInt(maxElement + 1);
store3 = rando.nextInt(maxElement + 1);
} else {
same = false;
}
}
int sum = store1 + store2 + store3;
sumCounts.put(sum, 1 + sumCounts.getOrDefault(sum, 0));
}
// now print the counts of each sum.
System.out.printf("%-20s%-20s\n", "Trial Sum", "Count of Occurrence");
for (int sum = 3; sum <= 84; sum++) {
if (sumCounts.containsKey(sum)) {
System.out.printf("%-20d%-20d\n", sum, sumCounts.get(sum));
}
}
}
public static void main(String[] args) {
Lottery lot = new Lottery();
lot.runLottery();
}
}
************************************************** Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.
Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.
I created this program using the Java-oriented programming application known as Eclipse for a lottery system,...
I am currently using eclipse to write in java.
A snapshot of the output would be greatly appreciated to verify
that the program is indeed working. Thanks in advance for both your
time and effort.
Here is the previous exercise code:
/////////////////////////////////////////////////////Main
/*******************************************
* Week 5 lab - exercise 1 and exercise 2: *
* ArrayList class with search algorithms *
********************************************/
import java.util.*;
/**
* Class to test sequential search, sorted search, and binary search
algorithms
* implemented in...
CREATE A CONSOLE APPLICATION USING ECLIPSE. import java.util.ArrayList; import java.util.Random; /* Computer Science and Information Systems * Programming and Problem Solving II * Code Practice and Review * Stockton University * * The following exercise will walk you through a lot of the * topics covered in the first installment of the series. * * This specific exercise uses climate data. * * Topics include: * CLASSES AND METHODS ARRAY/ARRAYLIST CONDITIONAL LOGIC (IF/ELSE-IF/SWITCH) ITERATION (FOR/DO/WHILE) STRING MANIPULATION (SUBSTR/LENGTH/CHARAT) FUNDAMENTAL TOOLS...
After pillaging for a few weeks with our new cargo bay upgrade, we decide to branch out into a new sector of space to explore and hopefully find new targets. We travel to the next star system over, another low-security sector. After exploring the new star system for a few hours, we are hailed by a strange vessel. He sends us a message stating that he is a traveling merchant looking to purchase goods, and asks us if we would...
I have a Graph.java which I need to complete four methods in the java file: completeGraph(), valence(int vid), DFS(int start), and findPathBFS(int start, int end). I also have a JUnit test file GraphTest.java for you to check your code. Here is Graph.java: import java.util.ArrayList; import java.util.LinkedList; import java.util.Queue; import java.util.Stack; /* Generic vertex class */ class Vertex<T> { public T data; public boolean visited; public Vertex() { data = null; visited = false; } public Vertex(T _data) { data =...
USE JAVA PROGRAMMING Create a program that would collect list of persons using double link list and use a Merge Sort to sort the object by age. Create a class called Person : name and age Create methods that add, and delete Person from the link list Create a method that sorts the persons' objects by age. package mergesort; public class MergeSortExample { private static Comparable[] aux; // auxiliary array for merges public static void sort(Comparable[] a) { aux =...
This is my code for my game called Reversi, I need to you to make the Tester program that will run and complete the game. Below is my code, please add comments and Javadoc. Thank you. public class Cell { // Displays 'B' for the black disk player. public static final char BLACK = 'B'; // Displays 'W' for the white disk player. public static final char WHITE = 'W'; // Displays '*' for the possible moves available. public static...
1) Consider the following Java program: 1 public class HelloWorld { 2 // My first program! 3 public static void main(String[] args) { 4 System.out.println("Hello, World!"); 5 } 6 } What is on line 1? a. a variable declaration b. a statement c. a method (subroutine) definition d. a comment e. a class definition 2) Which one of the following does NOT describe an array? a. It can be used in a for-each loop. b. It has a numbered sequence...
please edit my java code perferably on jgrasp version 50.0 , wont complie correctly :( the program is supposed to read from my input file and do the following 1) print out the original data in the file without doing anything to it. 2) an ordered list of all students names (last names) alphabetically and the average GPA of all student togther . 3) freshman list in alphabeticalorder by last name with the average GPA of the freshmen...
need help editing or rewriting java code, I have this program
running that creates random numbers and finds min, max, median ect.
from a group of numbers,array. I need to use a data class and a
constructor to run the code instead of how I have it written right
now. this is an example of what i'm being asked
for.
This is my code:
import java.util.Random;
import java.util.Scanner;
public class RandomArray {
// method to find the minimum number in...
Could you please add Round Robin CPU scheduling algorithm with quantum 10 in this code? Scheduling.java import java.util.ArrayList; import java.util.Random; import java.util.Scanner; public class Scheduling { public static void main(String[] args) { ArrayList<Proc> pr = new ArrayList<Proc>(); ArrayList<Proc> pr1 = new ArrayList<Proc>(); ArrayList<Proc> pr2 = new ArrayList<Proc>(); ArrayList<Proc> pr3 = new ArrayList<Proc>(); int count=0; Random ran = new Random(); boolean unique=false; int num=0; for(int i=0;i<=5;i++){ unique=false; Proc p1=new Proc(); while(!unique){ num=ran.nextInt(10) + 1; if(i==0) break; for(int j=0;j<i;j++){ if(num==pr.get(j).id){ unique=false;...