C++ CODE AND FLOWCHART Description: Lottery Application Design a program that si
ID: 3697424 • Letter: C
Question
C++ CODE AND FLOWCHART
Description: Lottery Application Design a program that simulates a lottery (Loteria traditional (billetes) and LOTO). The user can choose between lottery and LOTO. The program should have an array of five integers in the lottery version, and six digits in the LOTO version. The program should generate a random number in the range of 0 through 9 for each element in the array (lottery) and in the range of 1 to 46 for LOTO version. The programs should generate a file with the winner number, type of lottery, # of matching digits (LOTO) and the prize. LOTO version: The program should display the random numbers stored in the lottery array and the number of matching digits. If all of the digits match, display a message proclaiming the user as a grand prize winner of $1,000,000. If there are five matching digits, the prize should be $500,000 and if there are four matching digits, the prize should be $250,000 and if there are three matching digits, you have a free new ticket. Loterfa traditional version: If the user match the number, the prize will be $ 250,000.Explanation / Answer
#include<iostream.h>
#include<stdlib.h>
void main()
{
string type;
int a[5],b[6],i,n[6],c=0;
cout<<"Enter type";
cin>>s;
if(strcmp(s,"lottery")==0)
{
for(i=0;i<5;i++)
{
a[i]=rand%9;
}
for(i=0;i<5;i++)
{
cout<<"enter "<<i+1<<" number";
cin>>n[i];
}
for(i=0;i<5;i++)
{
if(a[i]==n[i])
{
c++;
}
}
}
else
{
for(i=0;i<6;i++)
{
b[i]=rand%46+1;
}
for(i=0;i<6;i++)
{
cout<<"enter "<<i+1<<" number";
cin>>n[i];
}
for(i=0;i<6;i++)
{
if(b[i]==n[i])
{
c++;
}
}
}
if(c==6)
cout<<"You won prize $1,000,000";
if(c==5)
cout<<"YOu won prize $500,000";
if(c==4)
cout<<"YOu won prize $250,000";
if(c==3)
cout<<"YOu won free ticket";
ofstream out("Result.txt);
out<<s<<","<<c;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.