Last active
March 19, 2022 19:52
-
-
Save elvis-sande/82a921589caf1adf213f67cfda9697a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
WHAT ARE YOUR ODDS OF WINNING FOOTBALL BETTING / JACKPOT? | |
TLDR: | |
if total cash(c) = participants(p) x individual ammount(a) | |
and number of bets available(b) = c / stake ammount(s) | |
and universe of bets in x matches(u) = 3 ^ number of matches(m) | |
then | |
percent chance(pc) = (((p x a) / s) x 100) / (3 ^ m) | |
pc = (b x 100) / u | |
*/ | |
//TODO: Add formula for calculating bonus win, the odds are better. | |
import java.util.Scanner | |
import kotlin.math.round | |
fun main() { | |
val scanner1 = Scanner(System.`in`) | |
val chScanner = Scanner(System.`in`) | |
var divider = "==========================================================" | |
println("Hello. This program will calculate your odds of winning football bets or the jackpot") | |
println("Let's Go!") | |
println(divider) | |
println("How many people are you?") | |
var people = scanner1.nextInt() | |
// Get the ammount the user wants to gamble | |
println("How much money is everyone contributing?") | |
var contribution = scanner1.nextInt() | |
var cash = (people * contribution) | |
println("You have ksh $cash in total") | |
println(divider) | |
fun calculateChance(bonus: Int = 0){ | |
//Get the number of matches they want to bet on; | |
println("How many matches are in the betslip you are going to place?") | |
var matches = scanner1.nextInt() | |
// The line below will determine how many bets they can place with the money they have | |
println("How much does it cost to place a single bet?") | |
var stake: Int = scanner1.nextInt() | |
var bets = (cash / stake) | |
println("With ksh ${cash}, you can place up to ${bets} different bets ") | |
println(divider) | |
//calculate universe of outcomes for the number of matches specified | |
val base = 3 | |
var universe = (Math.pow(base.toDouble(), matches.toDouble())).toInt() // 3^g | |
println ("For ${matches} games, there are ${universe} different possible results/betslips") | |
println(divider) | |
// Determine odds as a percentage and ratio. | |
var percentChance = Math.round(((bets * 100.0) / universe) * 1000.0) / 1000.0 | |
println("If you place ${bets} bets:") | |
println("You have a ${percentChance}% chance of winning the jackpot") | |
// ratio is bets : universe | |
var ratio = Math.round(universe.toDouble() / bets) | |
println("You have 1 : ${ratio} chances of winning") | |
println(divider) | |
} | |
// Calculate payout for jackpot. | |
println("Is it a jackpot bet?(y/n)") | |
var jpAns = chScanner.next().single() | |
if (jpAns == 'y'){ | |
println(divider) | |
println("How much is the jackpot?") | |
var jackpot = scanner1.nextInt() | |
println(divider) | |
calculateChance() | |
// Determine how the ammount will be shared among the participants | |
println("Do you still have hopes of winning? (y/n)") | |
var hopeAns = chScanner.next().single() | |
println(divider) | |
if (hopeAns == 'y'){ | |
println("Including yourself/team, how people in total do you think will win the jackpot?") | |
var jpKeWins = scanner1.nextInt() | |
println(divider) | |
println("How people in your group do you think will win?") | |
var jpGrpWins = scanner1.nextInt() | |
var jpPayout = ((jackpot / jpKeWins) * jpGrpWins) | |
println(divider) | |
println("If ${jpGrpWins} people in your group win the jackpot;") | |
println(" you will receive a total winning of ksh ${jpPayout}") | |
println("You will each receive ksh ${jpPayout / people}") | |
println(divider) | |
} | |
else return; | |
} | |
else { | |
calculateChance() | |
println("How much is the prize for the bet?") | |
var prize = scanner1.nextInt() | |
var betPayout = (prize / people) | |
println(divider) | |
println("If the ${people} of you win the ksh ${prize} ;") | |
println("Each of you will receive ksh ${betPayout}") | |
println(divider) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment