whats the code for this

Powerball® is a combined large jackpot game and a cash game. Every Wednesday and Saturday night at 10:59 p.m. Eastern Time, we draw five white balls out of a drum with 69 balls (1-69) and one red ball out of a drum with 26 red balls (1-26). Draw sales cut off at least 59 minutes before the draw. Check for local cut-off time.

Players win by matching one of the 9 Ways to Win. The jackpot (won by matching all five white balls in any order and the red Powerball) is either an annuitized prize paid out over 29 years (30 payments) or a lump sum payment. Each ticket costs $2. If the winner chooses the annuity, the annual payment will be increased each year by the percentage set out in the Powerball game rules.

Your assignment is to write a EZ-Play program that would deliver 6 lucky numbers (5 white ball numbers and 1 red power ball number) for every game the player pay



The code starts off like this and I do not know how to do the rest.

#include <iostream>
#include <ctime>
using namespace std;

const int WHITEBALLS = 69;
const int WHITEPICKS = 5;
const int REDBALLS = 26;
Last edited on
Hello sonia123,

Welcome to the forum.

The code starts off like this and I do not know how to do the rest.

If you are telling me this my first suggestion is to go back to your books. Or maybe take a look at: http://www.cplusplus.com/doc/tutorial/functions/
You should also go over: http://www.cplusplus.com/doc/tutorial/control/

In all the examples there is a main function which would be your next step in the program.

You may want to start with a greeting message and maybe what the program does. Followed by a prompt to ask the user how many plays they want.

You may want to call a function that generates the random numbers.

Just the first thoughts that came to mind. One point here is work on the program in small steps like the opening message and input. Once you have input and something to work with you can take the next step.

In your header files you will need to include <stdlib.h> for "rand()" and "srand()".

An A+ on the constant variable using capital letters.

I do not know where you picked up on the line using namespace std;, but consider this:

Try to avoid using using namespace std; in your programs it may seem easy now, but WILL get you in trouble some day.

It is better to learn to qualify what is in the standard name space with "std::" and then to learn what is in the standard name space now while it is easy. And not all at once to try to keep a job.

What you are most likely to use for now is "std::cout", "std::cin" and "std::endl". About a week or so of typing this and you will not even notice that you are doing it.

Hope that helps,

Andy
Topic archived. No new replies allowed.