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
Rudiy27
3 years ago
6

You’re going to write a program that models the Littleton City Lotto (not a real Lotto game). The program is going to allow to u

ser to first select their lotto numbers. The program will then randomly generate the winning lotto numbers for the week and then check the winning numbers against the random ticket the user played in the Lotto to see how many numbers the user guessed correctly.
Engineering
1 answer:
sveta [45]3 years ago
8 0

Answer:

Explanation:

// Include the required

// header files.

#include <iostream>

#include <cstdlib>

#include <iomanip>

#include <ctime>

#include <string>

// Use the

// standard namespace.

using namespace std;

// Define the function NoDuplicates(),

// to check whether a value is already

// present in an array or not.

int NoDuplicates(int arr[], int size, int val)

{

// Run the loop to

// traverse the array.

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

{

// If the value is already present

// in the array, return 0.

if(arr[i] == val)

{

return 0;

}

}

// Otherwise, return 1.

return 1;

}

// Define the function getLottoPicks().

void getLottoPicks(int UserTicket[])

{

int currNum;

//

// Run the oop to get 7

// numbers from the user.

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

{

// Prompt the user

// to enter the number.

cout << "Please enter number "<<i+1<<":";

// Read and store

// the number.

cin >> currNum;

// Run the loop till the

// entered number is valid.

while(true)

{

// If the number is out of range,

// display an error message.

if(currNum>40 || currNum<1)

{

cout << "The number must between 1 and 40. ";

}

// Otherwise, if the number is

// already present in the array,

// display an error message.

else if(NoDuplicates(UserTicket, i, currNum) == 0)

{

cout << "No duplicate numbers are accepted. ";

}

//Otherwise if the number is valid,

// break out of the loop.

else

{

break;

}

// If the number was invalid,

// prompt the user to enter the number again.

cout << "Please enter another number:"<<endl;

cin >> currNum;

}

// Store the number in the array.

UserTicket[i] = currNum;

}

}

// Define the function GenWinNums().

void GenWinNums(int WinningNums[7])

{

int currNum;

// Run the loop to

// generate 7 numbers.

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

{

// Generate a random number

// in the range 1-40.

currNum = (rand()%40) + 1;

//Run the loop till the

// generated number is valid.

while(NoDuplicates(WinningNums, i, currNum) == 0)

{

// If the generated number was

// a duplicate, generate another number.

currNum = (rand()%40) + 1;

}

// Store the number in the array.

WinningNums[i] = currNum;

}

}

// Define the function getWinnings().

string getWinnings(int numMatches)

{

// Return the winnings as

// per the number of matches.

switch(numMatches)

{

case 0:

case 1:

case 2:

return "SORRY NOTHING";

case 3:

return "FREE TICKET";

case 4:

return "NOT BAD - $100";

case 5:

return "LUCKY YOU! - $5,000";

case 6:

return "GREAT! - $100,000";

case 7:

return "JACKPOT - 1 MILLION";

}

return "Invalid Matches";

}

// Define the function displayResults().

void displayResults(string name, int UserTicket[], int WinningNums[])

{

int numMatches = 0;

string winnings;

// Run the loop to convert

// the name to uppercase.

for(int i=0; i<name.size(); i++)

{

name[i] = toupper(name[i]);

}

// Run the loop to find

// the number of matches.

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

{

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

{

if(UserTicket[i] == WinningNums[j])

{

numMatches++;

break;

}

}

}

// Get the winnings as per

// the number of matches.

winnings = getWinnings(numMatches);

// Display the results.

cout << endl

<< name << "'s LOTTO RESULTS" << endl;

cout << "------------------------"<<endl;

cout << "WINNING TICKET NUMBERS:";

// Run the loop to display

// the winning numbers.

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

{

cout << setw(3) << WinningNums[i];

}

cout << endl;

cout << setw(13) << name << "'s TICKET:";

// Run the loop to display

// the user ticket.

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

{

cout << setw(3) << UserTicket[i];

}

cout << endl;

cout << "RESULTS:"<<endl;

cout << "--------"<<endl;

cout << "Number Matches: " << numMatches << endl;

cout << "Winnings : " << winnings << endl

<< endl;

}

// Define the

// function menu().

void menu()

{

cout << "LITTLETON CITY LOTTO MODEL:"<<endl

<<"---------------------------"<<endl

<<"1) Play Lotto"<<endl

<<"q) Quit Program"<<endl

<<"Please make a selection:"<<endl;

}

// Define the

// main() function.

int main() {

// Set the random seed.

srand(time(NULL));

// Define an array to store

// the user ticket.

int UserTicket[7];

// Define an array to

// store the winning numbers.

int WinningNums[7];

char userChoice = '0';

string name;

// Run the loop till

// the user wants to quit.

while(userChoice != 'q')

{

// Display the menu.

menu();

// Read and store

// the user choice.

cin >> userChoice;

// Perform the required action

// as per the user choice.

switch(userChoice)

{

case '1':

cout << "Please enter your name:"

<< endl;

cin >> name;

getLottoPicks(UserTicket);

GenWinNums(WinningNums);

displayResults(name, UserTicket, WinningNums);

break;

// If the user chooses to quit,

// display a message.

case 'q':

cout << "Thank you for"

<<" using the program."<<endl;

break;

// Display an error message

// for invalid selection.

default:

cout << "Invalid selection."

<< endl;

}

}

// Return from

// the main() function.

return 0;

}

You might be interested in
A glass tube is inserted into a flowing stream of water with one opening directed upstream and the other end vertical. If the wa
Furkat [3]

Answer:

h=0.46m

Explanation:

From the question we are told that:

Velocity of water V=3m/s

Height=?

Generally, the equation for Water Velocity is mathematically given by

V=\sqrt{2gh}

Therefore Height h is given as

h=\frac{v}{2g}

h=\frac{3^2}{2*9.81}

h=0.46m

5 0
3 years ago
In RSA Digital Signature, Suppose Bob wants to send a signed message (x = 4) to Alice. The first steps are exactly t eps are exa
Luda [366]

Answer:

what r u on

Explanation:

4 0
3 years ago
What is the difference between filler and electrode in Welding? Can a filler be an electrode? Can an electrode be a filler? Why?
Vlada [557]

Explanation:

<u>Filler:</u>

  Filler is the material rod is used when we are joining two material by using welding process.If thickness of work piece is more so it will become compulsory to provide some filler material for making the welding join to withstand high stresses.

<u>Electrode:</u>

  Electrode is the element which is used to complete the electric circuit in welding .Some time electrode is connected with positive terminal and some time with negative terminal ,it depends on the requirement of welding process.In Tungsten inert gas welding electrode is connected negative terminal but on the other hand Metal inert gas welding electrode is connected with positive terminal.Electrode can be consumable non-consumable depends on the condition.

Yes electrode can be work as filler material ,in Metal inert gas welding wire is used as electrode as well as filler material.In Metal inert gas welding consumable electrode is used on the other hand Tungsten inert gas welding non-consumable electrode is used.In Tungsten inert gas welding if thickness of work pieces is less than 5 mm then no need to used any filler material but if thickness is more than 5 mm then we have to use filler material.

8 0
3 years ago
A(n) is a detailed, structured diagram or drawing.
monitta

Answer:

Schematics

Explanation:

A schematic is a detailed structured diagram or drawing. It employs illustrations to help the viewer understand detailed information on the machine or object being described. Its main aim is not to help the observer know what the object looks like physically. It is rather aimed at helping the viewer know how the machine works. This is achieved by only including key and important details to the drawing.

It is most times used in the blueprint and user guides of machines and gadgets used in the home to help users know how these things work so that they can do little fixings should there be such needs.

6 0
2 years ago
A square-thread power screw is used to raise or lower the basketball board in a gym, the weight of which is W = 100kg. See the f
KIM [24]

Answer:

power = 49.95 W

and it is self locking screw

Explanation:

given data

weight W = 100 kg = 1000 N

diameter d = 20mm

pitch p = 2mm

friction coefficient of steel f = 0.1

Gravity constant is g = 10 N/kg

solution

we know T is

T = w tan(α + φ ) \frac{dm}{2}     ...................1

here dm is = do - 0.5 P

dm = 20 - 1

dm = 19 mm

and

tan(α) = \frac{L}{\pi dm}      ...............2

here lead L = n × p

so tan(α) = \frac{2\times 2}{\pi 19}

α = 3.83°  

and

f = 0.1

so tanφ = 0.1

so that φ = 5.71°

and  now we will put all value in equation 1 we get

T = 1000 × tan(3.83 + 5.71 ) \frac{19\times 10^{-3}}{2}  

T = 1.59 Nm

so

power = \frac{2\pi N \ T }{60}     .................3

put here value

power = \frac{2\pi \times 300\times 1.59}{60}

power = 49.95 W

and

as φ > α

so it is self locking screw

 

8 0
3 years ago
Other questions:
  • List the thermal conductivities of five
    15·1 answer
  • Ayuda porfavor es para una tarea de mi capacitación de desarrollo microempresarial
    14·1 answer
  • The engine of a 2000kg car has a power rating of 75kW. How long would it take (seconds) to accelerate from rest to 100 km/hr at
    10·1 answer
  • An electric power plant uses solid waste for fuel in the production of electricity. The cost Y in dollars per hour to produce el
    10·1 answer
  • 4 Error-Correcting Polynomials (a) Alice has a length 8 message to Bob. There are 2 communication channels available. When n pac
    6·1 answer
  • Tech A says that proper footwear may include both leather and steel-toed shoes. Tech B says that when working in the shop, you o
    15·1 answer
  • Hi im ***ar and im doing sculptural but what should it be about star wars or Marvel
    9·1 answer
  • What is the most likely reason the rover won't travel in a straight line?
    9·1 answer
  • An ideal gas is contained in a closed assembly with an initial pressure and temperature of
    14·1 answer
  • A tank with a volume of 40 cuft is filled with a carbon dioxide and air mixture. The pressure within the tank is 30 psia at 70oF
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!