Blackbox Challenge 4

Description

The purpose of this challenge is examine the output and write the C++ source code that produces the given output and interaction.

Requirements

  1. You may use any combination of variable declarations, assignments, conditional statements, expressions, loops, etc
  2. Include <cstdlib> and <ctime> to enable the use of the built-in random number generator. See below on how to use the random number generator to have the computer produce integers within a given range.
#include <iostream>
#include <cstdlib>
#include <ctime> 
int main()
{
  int v1, v2, v3;

  srand(time(NULL));
    
  // these are examples on how to use the rand() function
  // v1, v2 and v3 are assigned random numbers below in the 
  // ranges shown in the comments
  v1 = rand() % 100;         // v1 in the range 0 to 99
  v2 = rand() % 100 + 1;     // v2 in the range 1 to 100
  v3 = rand() % 30 + 1985;   // v3 in the range 1985-2014

  return 0;
}

Sample Interaction / Output

$ [ run your program ]

You have $20.00 in your account

What is your wager? 5.00
Rock, Paper, Scissors (r/p/s): r

You showed rock, I showed scissors - You win!
You won $5.00, let your wager ride (y/n)? y
Ok, your wager is now 10.00

Rock, Paper, Scissors (r/p/s): s
You showed scissors, I showed paper - You win!
You won $10.00, let your wager ride (y/n)? n

You have $30.00 in your account

What is your wager? 20.00
Rock, Paper, Scissors (r/p/s): p
You showed paper, I showed rock - You lose!

You have $10.00 in your account

What is your wager? 10.00
Rock, Paper, Scissors (r/p/s): p
You showed paper, I showed scissors - You lose!

You have $0.00 in your account
GAME OVER 
$ [ back to the command prompt ]

LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT

CATALOG ID: CPP-BB0004

Print Requirements