Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that takes in integers values stake and goal and it does only one simulation and store the value cash for each itaration

Write a program that takes in integers values stake and goal and it does only one simulation and store the value cash for each itaration in array.

To solve this problem you need to know this: You don't know how many itarations will be, so create a large enough array in the beginning, like with N = 100000 and let the program crash if the simulation will get bigger than that. Also create a new array for the first array that scale the values so they are on the interval 0.0 to 1.0.

Use the following code as a skeleton for the program!

public static void main(String[] args) { int stake = Integer.parseInt(args[0]); // gambler's stating bankroll int goal = Integer.parseInt(args[1]); // gambler's desired bankroll

int cash = stake; while (cash > 0 && cash < goal) { bets++; if (Math.random() < 0.5) cash++; // win $1 else cash--; // lose $1 }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago