Create a Lottery application in Android Studio that simulates a lottery game. The application should allow the play to type in number to generate five numbers and one red ball. The constructor should use the Random class to generate a random number in the range of 1 through 69 for the red ball 1 through 26. In Android Studio
<!—activity_main.xml -->
<?xml version="1.0"
encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="simpleapps.my.lotteryapplication.MainActivity"
android:orientation="vertical"
android:layout_margin="10dp"
android:weightSum="100">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="Enter
White Balls : "
android:textColor="#000000"
android:textSize="22sp"
android:layout_weight="15"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:weightSum="100"
android:layout_margin="10dp"
android:layout_weight="15">
<EditText
android:id="@+id/wBall1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:inputType="number"/>
<EditText
android:id="@+id/wBall2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:inputType="number"/>
<EditText
android:id="@+id/wBall3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:inputType="number"/>
<EditText
android:id="@+id/wBall4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:inputType="number"/>
<EditText
android:id="@+id/wBall5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:inputType="number"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="horizontal"
android:weightSum="100"
android:layout_weight="15">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Enter Red
Ball : "
android:textSize="22sp"
android:textColor="#000000"
android:layout_weight="60"/>
<EditText
android:id="@+id/rBall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="30"
android:inputType="number"/>
</LinearLayout>
<Button
android:id="@+id/winBtn"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="15"
android:layout_gravity="center"
android:text="Winning
Numbers"
/>
<TextView
android:id="@+id/wResult"
android:layout_width="match_parent"
android:layout_height="0dp"
android:text="White
Balls : "
android:textColor="#000000"
android:textSize="20sp"
android:layout_marginTop="20dp"
android:layout_weight="15"/>
<TextView
android:id="@+id/rResult"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="20dp"
android:text="Red Ball :
"
android:textColor="#000000"
android:textSize="20sp"
android:layout_weight="15"/>
</LinearLayout>
<!— end of activity_main.xml -->
//MainActivity.java
package simpleapps.my.lotteryapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.Random;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private EditText wBall1, wBall2, wBall3, wBall4, wBall5, rBall;
private TextView wResult, rResult;
private Button winBtn;
private Random ran ;
private ArrayList<Integer> winningWhiteBalls;
private int winningRedBall;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ran = new Random();
winBtn = findViewById(R.id.winBtn);
wBall1 = findViewById(R.id.wBall1);
wBall2 = findViewById(R.id.wBall2);
wBall3 = findViewById(R.id.wBall3);
wBall4 = findViewById(R.id.wBall4);
wBall5 = findViewById(R.id.wBall5);
rBall = findViewById(R.id.rBall);
wResult = findViewById(R.id.wResult);
rResult = findViewById(R.id.rResult);
winBtn.setOnClickListener(this);
}
private void generateWinningNumbers()
{
winningWhiteBalls = new ArrayList<>();
for(int i=0;i<5;)
{
int num = ran.nextInt(69)+1;
if(!winningWhiteBalls.contains(num))
{
winningWhiteBalls.add(num);
i++;
}
}
winningRedBall = ran.nextInt(26)+1;
}
@Override
public void onClick(View v) {
int wball1,wball2,wball3,wball4,wball5, rball;
ArrayList<Integer> allowedNumbers = new ArrayList<>();
for(int i=1;i<70;i++)
allowedNumbers.add(i);
wball1 = Integer.parseInt(wBall1.getText().toString());
wball2 = Integer.parseInt(wBall2.getText().toString());
wball3 = Integer.parseInt(wBall3.getText().toString());
wball4 = Integer.parseInt(wBall4.getText().toString());
wball5 = Integer.parseInt(wBall5.getText().toString());
rball = Integer.parseInt(rBall.getText().toString());
boolean validNumbers = true;
if(!allowedNumbers.contains(wball1))
validNumbers = false;
else
allowedNumbers.remove(new Integer(wball1));
if(!allowedNumbers.contains(wball2))
validNumbers = false;
else
allowedNumbers.remove(new Integer(wball2));
if(!allowedNumbers.contains(wball3))
validNumbers = false;
else
allowedNumbers.remove(new Integer(wball3));
if(!allowedNumbers.contains(wball4))
validNumbers = false;
else
allowedNumbers.remove(new Integer(wball4));
if(!allowedNumbers.contains(wball5))
validNumbers = false;
else
allowedNumbers.remove(new Integer(wball5));
if(rball < 1 || rball > 26)
validNumbers = false;
if(!validNumbers)
Toast.makeText(getApplicationContext(),"Invalid number(s) selected",Toast.LENGTH_SHORT).show();
else {
generateWinningNumbers();
for (int i = 0; i < winningWhiteBalls.size(); i++)
wResult.setText(wResult.getText().toString() + " " + winningWhiteBalls.get(i));
rResult.setText(rResult.getText().toString() + " " + winningRedBall);
}
}
}
//end of MainActivity.java
Output:

Create a Lottery application in Android Studio that simulates a lottery game. The application should allow...
in a c++ visual studio 2017 ...Write a program that simulates a lottery. The program should have an array of five integers named lottery and should generate a random number in the range 0 through 9 for each element in the array. The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding element in the two arrays and keep a count of the digits that match. For...
Write a C++ program that simulates a lottery game. Your program should use functions and arrays. Define two global constants: - ARRAY_SIZE that stores the number of drawn numbers (for example 5) -MAX_RANGE that stores the highest value of the numbers ( for example 9 ) The program will use an array of five integers named lottery, and should generate a random number in the range of 0 through 9 for each element of the array. The user should enter...
Write a C++ program that simulates playing the Powerball game. The program will generate random numbers to simulate the lottery terminal generated numbers for white balls and red Powerball. The user will have the option to self-pick the numbers for the balls or let the computer randomly generate them. Set the Grand Prize to $1,000,000,000.00 in the program. Project Specifications Input for this project: Game mode choice – self pick or auto pick Five numbers between 1 and 69 for...
Write a Lottery class that simulates a 6-number lottery (e.g. "Lotto"). The class should have an array of six integers named lotteryNumbers, and another array of six integers named userLotteryPicks. The class' constructor should use the Random class to generate a unique random number in the range of 1 to 60 for each of the 6 elements in the lotteryNumbers array. Thus, there should be a loop that keeps generating random numbers until all 6 numbers are unique. The Lottery class...
in JAVA please and please show output!!
Create a JavaFX application that simulates the rolling of a pair of
dice. When the user clicks a button, the application should
generate two random numbers, each in the range of 1 through 6, to
represent the value of the dice. Use ImageView component to display
the dice. Six images are included in the project folder for you to
use. For example, the first picture below is the initial window,
after clicking the...
The Powerball lottery is played twice each week in 44 states, the District of Columbia, and the Virgin Islands. To play Powerball, a participant must purchase a $2 ticket, select five numbers from the digits 1 through 69, and then select a Powerball number from the digits 1 through 26. To determine the winning numbers for each game, lottery officials draw 5 white balls out a drum of 69 white balls numbered 1 through 69 and 1 red ball out...
Using C++ create a lotto program Lottery Design a program that simulates a lottery. Requirements: The program should have an array of 5 integers named lottery and should generate a random number in the range of 1 through 99 for each element of the array. The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding elements in the two arrays and keep a count of the digits that...
c++ please help You are going to create a PowerBall Lottery game with functions. First, you are going to generate 5 UNIQUE numbers between 1 and 69. Then you are going to generate the powerball number, which is a number between 1 and 26. Next you are going to ask the user for 5 numbers. Users should only be allowed to enter numbers in the range 1-69 for regular numbers, 1-26 for powerball pick. You will compare each of the...
Heads or Tails Create a JavaFX application that simulates a coin being tossed. When the user clicks a button, the application should generate a random number in the range of 0 to 1. If the number is 0, the coin has landed on “heads,” and if the number is 1, the coin has landed on “tails.” Use an ImageView component, and the coin images that you will find in this book’s Student Sample Programs to display the side of the...
I HAVE A PROBLE WITH THIS JAVA PROBLEM CAN ANYONE HELP ME
PLEASE.
Exercise 2 Write a program that simulates the Texas Powerball lottery. You will have to do research to find out how many numbers are drawn, and what the range(s) of the numbers are. For this exercise you need to create a class called "Powerbali", which exposes a public function called play'. This function accepts several parameters , which represent the individual numbers the player wants to play....