Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that takes in stake and goal and it does only one simulation and

ID: 3592104 • Letter: W

Question

Write a program that takes in 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
}

Explanation / Answer

#include <iostream>

#include <string>

using namespace std;

class BigInt {

private:

int arr[100];

public:

BigInt() { }

// this constructor should convert str into an array of ints,

// storing the values on the RIGHT SIDE of the array :)

BigInt(string str) {

}

// this constructor should save the num array into arr verbatim

BigInt(int num[100]) {

}

// this function gets the digit at 'index' from arr

int get(int index) {

}

// this function should add the argument "num"

// to the private array and return the sum

BigInt add(BigInt num) {

}

// this function should subtract the argument "num"

// from the private array and return the difference

BigInt sub(BigInt num) {

}

// this function will print the BigInt with NO leading zeroes

void print() {

}

};

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote