Please write the following 4 programs in Java. [Programs completed but with errors, could someone re-create it?]
Please make it as simple as possible. [I am a beginner]
1. How would you use random numbers to represent the drawing of a playing card? Write a loop to test your answer by generating 100 randomly drawn cards and verify that they are in the correct range by printing and looking them over.
2. How would you use random numbers to represent the roll of a six-sided die? Write a loop to test your answer by generating 25 random rolls and verify that they are in the correct range by printing and looking them over.
3. How would you use random numbers to represent the roll of two six-sided dice? Write a loop to test your answer by generating 50 random rolls and verify that they are in the correct range by printing and looking them over.
4. Write a loop to generate 100 random numbers between 0 and 1000, and then display output which would be similar to the following:
Your random number test produced the following results:
Average: 104
Sum: 10444
Min: 23
Max: 900
[Thank you]
package abc1;
import java.util.Random;
public class RandomProgram {
public static void main(String[] args) {
Random generator = new Random();
//# Program 1
int face=0, suit=0;
int i=0;
String[] suits = {"Spade", "Heart", "Diamod", "Club"};
String[] faces = {"Ace","2","3","4","5","6","7","8","9","10","J","K","Q"};
while(i<100) {
face = generator.nextInt(13); //13 cards in a suit
suit = generator.nextInt(4); //4 suits
System.out.println(suits[suit] + " - " + faces[face]);
i++;
}
//# Program 2
i=0;
while(i<25) {
int x = 1 + generator.nextInt(6);
System.out.println(x);
i++;
}
//# Program 3
i=0;
while(i<50) {
int x = 1 + generator.nextInt(6);
int y = 1 + generator.nextInt(6);
System.out.println(x + " - " + y);
i++;
}
//# Program 4
i=0;
double sum = 0;
double average = 0;
int min =0, max = 0;
while(i<100) {
int x = generator.nextInt(1000+1);
sum += x;
if(x<min)
min = x;
if(x>max)
max = x;
i++;
}
System.out.println("Your random number test produced the following results: ");
System.out.println("Average: " + sum/100);
System.out.println("Sum: " + (int)sum);
System.out.println("Min: " + min);
System.out.println("Max: " + max);
}
}



Please write the following 4 programs in Java. [Programs completed but with errors, could someone re-create...
question 2 in C programming please
PE-05b-01 (Six-sider) write a counter-controlled program that prompts the user to enter the number of times n to roll a six-sided die. The program should print to the screen the iteration of the loop and result for each roll 1 ) How many times would you like to roll? 3 roll 6 6 5 1 2) PE 05b 02 (Flash Cards) Write a counter-controlled program that creates addition problems for an elementary kid to...
Java programming Write a simulation of the Craps dice game. Craps is a dice game that revolves around rolling two six-sided dice in an attempt to roll a particular number. Wins and losses are determined by rolling the dice. This assignment gives practice for: printing, loops, variables, if-statements or switch statements, generating random numbers, methods, and classes. Craps game rules: First roll: The first roll (“come-out roll”) wins if the total is a 7 or 11. The first roll loses...
Please Use Python and provide explanations!!!! 1. Write a function called multiply_and_print that takes two numbers, multiplies them together, and prints out the sentence '____ times ____ is ____'. Ask the user for two numbers, and call multiply_and_print with their two numbers as arguments. 2.Write a function called roll_dice that rolls two six-sided dice and prints out the result of each die. Call it three times. (Remember, you can import the random module with the statement import random, and then...
In this assignment you are asked to write a Python program to determine all the prime numbers in between a range and store them in a list that will be printed when the range is searched. The user is prompted for two positive integer values as input, one is the start of the range and the other is the end of the range. If the user gives a negative value or enters a second number that is lower than the...
. 9. 10. 1. 11. 12. 13. 1. 14. 15. 16 2.1.3.4.1.5. 16. 17:18 Write a int method rolID20(int int m, Randomr) that returns how many times It takes to roll two numbers with a single 20 sided dice. The parameters to the method are as follows: into The first number you are trying to roll int m The second number you are trying to roll Randomr A Random object to simulate the dice rolls. Please see the documentation for...
I just need the code in c++ by using array and random number generation Write a function called rollDice. This function emulates rolling two 6-sided dice Choose two random numbers between 1 and 6 They should be random enough (pseudo-radom), not the same random number every time the function is run Add the numbers together and return the sum Note: it is not sufficient to merely randomly choose a number between 2 and 12, can you see why? Write a...
Write a Java program that deals a five-card poker hand and then determines which of the following hands are contained in it: high card, pairs, two pair, three of a kind, flush. Test only for those hands. Use the numbers from 0 to 51 to represent the cards of the poker deck. 1. To deal the cards, your main method should call a secondary method that selects a random card. The secondary method should accept 5 integers that represent the...
Write a program, which reads a list of student records from a file in batch mode. Each student record comprises a roll number and student name, and the student records are separated by commas. An example data in the file is given below. · SP18-BCS-050 (Ali Hussan Butt), SP19-BCS-154 (Huma Khalid), FA19-BSE-111 (Muhammad Asim Ali), SP20-BSE-090 (Muhammad Wajid), SP17-BCS-014 (Adil Jameel) The program should store students roll numbers and names separately in 2 parallel arrays named names and rolls, i.e....
Please i need helpe with this JAVA code. Write a Java program simulates the dice game called GAMECrap. For this project, assume that the game is being played between two players, and that the rules are as follows: Problem Statement One of the players goes first. That player announces the size of the bet, and rolls the dice. If the player rolls a 7 or 11, it is called a natural. The player who rolled the dice wins. 2, 3...
Create a loop that will populate a listbox with random values 14 pts The random numbers should range for ranging from 0 to 10 (10 must be a potential number that will be added). Keep adding values to the listbox until the sum of the values in the listbox equals or exceeds 100. After adding the values, tell me how many items are in the listbox, and the sum of the numbers, displaying these values in labels. Create a...