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]
3 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]3 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
An asymmetric encryption system utilizes how many keys?
ivanzaharov [21]
Two. One for encryption, and one for decryption. RSA is an example of an asymmetric encryption algorithm.
7 0
3 years ago
How many binary digits are in 10^100.
Basile [38]

Answer:

333 binary digits.

Explanation:

8 0
2 years ago
You are configuring a wireless network with two wireless access points. Both access points connect to the same wired network. Yo
-BARSIC- [3]

Answer:

b. Same SSID, different channel

Explanation:

The Service Set Identifier (SSID) is a sequence that is included in all of the sets in a wirless network and helps identify them as part of the network. Because both points connec to the same network they need the same SSID.

7 0
3 years ago
A network technician is setting up a wireless access point in the front office of a small company. The technician needs to disab
VladimirAG [237]

Answer:

He should disable UPnP technology to disallow devices to dynamically add themselves to the network without configuration.

Explanation:

  • UPnP stands for Universal Plug n Play.
  • It is an easiest way that allows gadgets to find all other devices connecting to your network.
  • This can also modify router settings to allow devices from outside the network to access the router.
  • External IP address can also be obtained by the gadget and a new port forwarding map can be set
  • So from all perspectives, UPnP is an open invitation for hackers to scan for the ports and hack into the device.
  • UPnP is a vulnerability to the secure system
6 0
3 years ago
The insertion sort algorithm sorts using what technique?
QveST [7]

Answer:

Iteration

Explanation:

The insertion sort is based on repetition of comparing one data array (or element in a list) with the others at its left to reorganize it, normally following a size criteria (from small to big or the other way around).

At each iteration, the algorithm takes one element and compares it one by one to the others until it fit the specified criteria. Later on, it creates a space, moving the other elements, to insert it. Later, it  goes to the next element and the iteration repeats all the way through. It has some advantages over other sorting algorithms because it is easy to deploy and program it in many different languages, but at the same time it can be terribly slow when sorting large amount of data.

7 0
2 years ago
Other questions:
  • If you are planning to carry a large balance on your credit card, which of the following credit card features should you look fo
    7·2 answers
  • A user is experiencing slow performance with their computer. A technician suspects the computer has a virus and runs antivirus s
    12·1 answer
  • 3) An example of interactive web page is<br>​
    11·1 answer
  • Which line is not a computer-generated forecast?Which line is not a computer-generated forecast?the black line representing 20th
    12·1 answer
  • Describe the following types of data hazards. RAW WAR WAW
    13·1 answer
  • Which of the following Google tools support collaboration? Docs Sheets Slides All of the Above
    13·1 answer
  • 1. Define lexemes. Give an example of an lexeme in any programming language.<br>​
    10·1 answer
  • Having data in a column formatted differently based on value is known as
    7·1 answer
  • How did machines get involved throughout the years?
    13·1 answer
  • Write an algorithm to create a customer’s bill for a company. The company sells only five different products. TV, VCR, Remote Co
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!