1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
IgorC [24]
2 years ago
12

Lottery Number Generator Design a program that generates a 7-digit lottery number. The program should have an Integer array with

7 elements. Write a loop that steps through the array, randomly generating a number in the range of 0 through 9 for each element. Then ask the user to input 7 numbers into another array. Display the lottery numbers and the user’s chosen numbers. Then display if the user is a lottery winner or should try again. Continue this loop until the user types in ‘x’ to quit.
Computers and Technology
1 answer:
Nikolay [14]2 years ago
5 0

Answer:

/******************************************************************************

                             Online C++ Compiler.

              Code, Compile, Run and Debug C++ program online.

Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

#include <string>

#include <sstream>

using namespace std;

bool equal(int sys[],int user[])

{

    for (int i=0;i<7;i++)

{

 if(sys[i]!=user[i]){

     return false;

 }

}

return true;

}

int main()

{

int sys[7];

int user[7];

int min=0

;int max=9;

string userinput;

while(0==0){

for (int i=0;i<7;i++)

{

    sys[i]=rand() % (max - min + 1) + min;

}

cout <<endl;

   cout<<"enter numbers"<<endl;

for (int i=0;i<7;i++)

{

 getline (cin,userinput);

    if(userinput=="x"){

        return 0;

    }

    else{

 stringstream(userinput) >> user[i];

   

    }

}

     cout<<"User number"<<endl;

for (int i=0;i<7;i++)

{

    cout << user[i];

}

    cout<<"system number"<<endl;

for (int i=0;i<7;i++)

{

    cout << sys[i];

}

if(equal(sys,user))

{

   cout<<"You won !"<<endl;

}else {

       cout<<"Try again :("<<endl;

}

}

   return 0;

}

Explanation:

Using c++ rand function generate a random number between 0-9.

Formula for random number is rand (max-min +1)+min.

Run this in a loop for 7 time and store each number to an array index in sys array which is for system generated number.

now using string take input from user and check if input is x close program else use stringstream to parse input string to int and store it in user array. Stringstream is a cpp header file used for parsing and handling of strin g inputs. Run this program in loop for 7 times.

Now create a function of type boolean denoted by "bool". This will take both arr as parameter and check if both are equal or not. It compares eac index of user array against each index of sys array and if both values are not equal returns false.

You might be interested in
If you are using a sprite for your MakeCode Arcade game, which code block
xeze [42]

Answer:

set mySprite block

Explanation:

BRAINLIEST?

8 0
2 years ago
Read 2 more answers
Icon view, list view, and details view are all common views provided by which kind of program?
RideAnS [48]
The standard program that uses common views such as the icon view, list view, and details view would be the program known as "File Explorer" (Windows) or "Finder" (Mac). This program uses all the views to make selecting and tracking down certain files a much more painless and easier process to complete.

Hope this helps and good luck! :)
6 0
3 years ago
Read 2 more answers
Horizontal and vertical flips are often used to create ___.
mixer [17]

Answer:

Rotation of an image

Explanation:

The correct answer is -  Rotation of an image

Reason -

When you rotate an object, it moves left or right around an axis and keeps the same face toward you.

When you flip an object, the object turns over, either vertically or horizontally, so that the object is now a mirror image.

5 0
2 years ago
What is the difference between the animation with shape hints and the animation without the shape hints?
soldier1979 [14.2K]
Animation with shape is 3D animation
Animation without shape is 2D animation
4 0
3 years ago
How can I create a pluralsite account for free to sign in​
nevsk [136]

Answer:

I mean I need points but I'm not sure my advice is to look it up or look on y0utube : )

Explanation:

6 0
3 years ago
Other questions:
  • Ron is creating building blocks in Word. How can he make the building blocks that he created available?
    11·2 answers
  • Savings accounts typically offer more interest than what
    10·1 answer
  • Jana keeps receiving friend requests from strangers on a social media site. This is making her uncomfortable.
    15·2 answers
  • I WILL MARK THE BRAINIEST!!!!!!!!!!!!! 50 POINTS!!!!!!!
    5·2 answers
  • When Liam went to print his presentation, the boot process established the connection to the printer, sent the presentation to t
    12·1 answer
  • Need Help!
    9·1 answer
  • A(n) ____ string contacts the data source and establishes a connection with the database using the Data Source Configuration Wiz
    5·1 answer
  • Julie is purchasing new shoes on a website for her favorite store. Which of the following would indicate that a website is a sec
    6·1 answer
  • Wow that funny a heck
    7·1 answer
  • NEED HELP ASAP!!!
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!