Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9208409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:36:44+00:00 2026-06-18T00:36:44+00:00

making an android app to do a lottery prize system. I want to randomly

  • 0

making an android app to do a lottery prize system.

I want to randomly select winners of prizes. but each of the prizes are in different amounts. they are currently stored in a database as three columns, first is index id, auto incremented, the second is the name of the prize, and third is the number of each of these prizes.

for example the most expensive prize is a car and there will be only one of them. but the next cheaper prize will be a small 50 cc scooter, about 10 of them. and the list goes down to to a pencil and pen set where there are 800 winners for this prize.

so the chance of winning the pencil and pen set is much higher than the other prizes.

i am trying to get the idea on what is the best way to code this. i understand that random number generator and even a better one that more evenly distributes true random numbers.

what i am not clear on is the best way to go about this with the different frequency for each of the prizes.

can someone point me in the right direction for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:36:45+00:00Added an answer on June 18, 2026 at 12:36 am

    Easiest and least error prone way => put all the prizes in an array. Each prize should be put as many times as there are prizes of the given type. Then generate a random number up to the size of the array and see what is the prize at the given index.

    Note that this only considers the case when you know the given user will win a prize. Maybe you should first give a way bigger chance for the user not to win anything for instance say you have 4000 total prizes and you want a user to win a prize with 1/40 chance. So generate a random number up to 40*4000 = 160000 and if the number is not less than 4000 the user wins nothing, otherwise he wins the prize at the index corresponding to the generated value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making an android app. I have a main activity and i want
So I'm making an android app that has more than 100 buttons,but you know
I am making my first android app. I want to save an array of
I am making an Android app using a tutorial, but I have an error
I tried making my first android app. It works well but strangely when I
I'm making a android quotes app which use data in database. i want to
I'm making my first android app and I want to to make a test
I am making an android app in which I need to make different tables
I am making an android app in which i want to make a dynamic
I am making an android app that publishes facebook posts. I want it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.