Dev C++ Lottery
I have to make a program that simulates a lottery. The program should have an array of 5 digits named winningdigits, a randomly generated number in the range of 0 through 9 for each element in the array. The program should ask the user to enter 5 digits and should store them in a second integer array named player. The program must compare corresponding elements in two arrrays and count how many digits match.
This is an example: There are two matching digits, elements 2 and 4.
winningDigits: 7, 4, 9, 1, 3
player: 4, 2, 9, 7, 3
Print out the matches and how much money the user made.
Money made = Match(es) X 100
Example:
2 Matches = $200
Development Lotteries Board celebrates its 37th anniversary Prizes from Development Lotteries Board to the Super Winners of Lagna Wasana and 21 millionaires Draw of the special lottery of Super Ball “Super Chance” on 30th January. Electronic Diversity Visa Lottery. The DV-2021 Diversity Visa program registration period was between October 2, 2019 and November 5, 2019. All submission.
So far I have this, I'm not sure how to make them match. Do I do the same type of thing for player like I did for winningDigits? I'm not really sure what to do after this?
- Do you want insider information on DC Lottery games, prizes and events? Need to be in-the-know about jackpots, game launches and promotions? Membership has its privileges and the DC Lottery’s Players’ Club is where you want to be. Get in on the fun! Learn More Login.
- South Carolina (SC) lottery results (winning numbers) and prize payouts for Pick 3, Pick 4, Palmetto Cash 5, Lucky for Life, Powerball, Mega Millions.
- 3 Contributors
- forum 6 Replies
- 878 Views
- 12 Hours Discussion Span
- commentLatest Postby Ancient DragonLatest Post
Ancient Dragon5,243
I assume the array of winning digits can not contain duplicate numbers -- for example this would be illegal: 7 1 4 7 2 5 because the number 7 appears more than once. If that is correct, then you need to expand the loop on line 12 to check the array to see if the value returned by line 13 already exists in the array.
Sonic Academy - ANA 2.0.3 r2 VSTi, AAX, AU WIN.OSX x86/x64 566 MBFinally, our long-awaited launch was completed! Combine up to 3 oscillators with other sound shaping functions and you will understand how beautiful the complex sounds can be in ANA 2. We spent many thousands of hours perestroika and redesigning each corner of the ANA to create a beautiful elegant and powerful synthesizer. It is very easy to use, but with an extensive set of tools that allows you to create complex and exciting sounds.For 3 years, while in the process of creation, our synthesizer is finally ready, and we can not wait until you try it!So fresh, so neat: We completely redesigned the interface with support for HD Retina with classic white and new black skins to choose from. With all the new features that we packed into ANA 2, it was difficult to imagine all this on the screen, but we managed to do this, giving you full control and flexibility of what ANA 2 has to offer.Transform your sound with 3D waveforms: With our 3D oscillator, complex sounds are just turning the knob! Ana 2 vst download.
line 15: a[10] accesses one element beyond the end of the array, that is, there is no 10th element. Remember, arrays always start numbering with 0, so the last elment in that array is a[9].
Why does arry a contain 10 elements when only the first 5 are used?
You need to add something before line 15 to get user input for 5 digits. Again, you will probably want to check for duplicates.
It probably doesn't matter if the digits in the two arrays are in the same order. So you might use a 3d array to check off the digits that appear in both arrays. You could use a bool array for that.
bool checks[5] = {false};
Now loop through both the first two arrays. If the first value in the second array (user inputs) appears anywhere in the first array (winningDigits) then set checks[0] to true. Do that for each of the other digits in the user inputs array. When done, all you have to do is count the number of true values in the checks array.
Once you get all that done the rest should be fairly easy to print out.
Dev C Lottery Winning
Don't attempt to program all this at the same time. Do a little bit, compile, correct errors then repeat.
Dev C++ Loop
// Lottery Number Game
#include <iostream>
// so we dont have to use std: anymore
using namespace std;
int main () // Start of program
{
int lotto1; // first lotto number
int lotto2; // second lotto number
int guess1; // users first guess
int guess2; // users second guess
lotto1 srand 1 >= && <=10; // generates lotto number 1
lotto2 srand 1 >= && <=10; // generates lotto number 2
cout << 'Welcome to the Lottery'n; // welcome screen
cout << ' Enter your first integer guess between 1 and 10n '; // promt for fisrt guess
cin >> guess1; // read first guess
cout << ' Enter your secend intger guess between 1 and 10n '; // promt for second guess
cin >> guess2; // read second guess
if (( guess1 lotto1 lotto2) && (guess2 lotto1 lotto2)) cout << ' YOU WIN!n'; // Winning Result
if (guess1 != lotto1 lotto2) cout << ' You LOSE! hahahan '; // Losing result
if (( guess1 lotto1 lotto2) (guess2 lotto1 lotto2)) cout << ' You got one of the numbers correct, but you still LOSEn'; // Almost winning, but losing result
return 0; // end program
} // end function main