id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

davereed@creighton.edu csc222 > streakOdds
prev  |  next  |  chance

streakOdds() - Recall that a fair coin has a 50% chance of coming up heads. The probability of flipping two heads in a row is (0.5)^2 = 0.25 = 25%; three heads in a row is (0.5)^3 = 0.125 = 12.5%, and so on. In general, if the odds of some event occurring are P percent, then odds of it occurring N times in a row are 100*((P/100)^N). Given the percentage P for an event and positive integer N, calculate and return odds of the event occurring N times in a row.


streakOdds(50, 1) → 50.0
streakOdds(50, 2) → 25.0
streakOdds(50, 3) → 12.5

...Save, Compile, Run (ctrl-enter)

public double streakOdds(double per, int numTimes) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Post-solution available

Copyright Nick Parlante 2017 - privacy