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
Which clauses in the Software Engineering Code of Ethics are upheld by a whistleblower (check all that apply). a. "Respect confi
garri49 [273]

Answer:

c. and d

Explanation:

As a whistle-blower, one of your aim is to guide against unethical dealings of other people , hence you are creating an environment that uphold ethical conduct,

In addition, whistle-blowing will disclose all imminent dangers to the software community thereby preventing security breaches.

6 0
3 years ago
6. What types of injuries can occur in an electronics lab and how can they be prevented?
marysya [2.9K]

Answer:

The most common injuries in a chemistry lab is making a fire, heat burns, chemical burns, cuts and scrapes, contamination, inhalation, and spills and breaks.

1.) You can prevent making a fire by making sure you close and seal flammable materials.

2.) You can prevent heat burns by teaching the students how to properly use tongs,water baths, and other cooling equipment. 

3.) You can prevent chemical burns by treating the chemicals with caution, measure carefully, and use the approved containers.

4.) You can prevent cuts and scrapes by telling the students how to use the blades safely, and also when they are disposing broken or sharp items they should know how to wrap them up so no one else will get hurt. 

5.) You can prevent contamination by washing your hands, protect their clothing and skin with a lab coat or a lab apron, gloves and glasses, and cleaning your area where the germs of the chemicals were so no one will become.

6.) You can prevent inhalation by opening up windows, using ventilation fans, and using an equipment that measures the amount of gas emission in a room.

7.) Finally, you can prevent spills and breaks by telling the students what will happen if anything spills, and tell them to clean up.  

8 0
3 years ago
A non-licensed person may be the SOLE owner of a civil, electrical, or mechanical engineering business under which of the follow
kotegsom [21]

Answer:

(d) None. No provisions exist.

Explanation:

B&P Code § 6738 prohibits a non-licensed person from being the sole proprietor of an engineering business. The non-licensed can be a partner in an engineering business that offers civil, electrical, or mechanical services. It is mandatory that at least one licensed engineer must be a co-owner of the business.

5 0
3 years ago
A farmer wants to buy a 10 kg bag of fertilizer (organic soil). They have the choice between two merchants. Merchant A sells the
sergejj [24]

Answer:

Since the farmer wants to buy a 10 kg bag of fertilizer, he should buy it from merchant A. However, Merchant A and B are selling at the same price for a unit value. In other words, Both Merchant A and B are selling 1kg of dry fertilizer for $1.

Explanation:

Which merchant has the better deal means which merchant offers the farmer a better deal.

For Merchant A,  10 kg bag = $10

meaning it contains a real 10 kg bag of dry fertilizer which the farmer can use without losing any Kg to drying.

While for Merchant B, 10 kg bag = $8

where the 10kg = 80% dry fertilizer + 20% water content

But the farmer can only use the solid constituents of the bag which means,

Merchant B is giving 80/100 x 10Kg of dry fertilizer for $8

That is, 8kg for $8

Since the farmer wants to buy a 10 kg bag of fertilizer, he should buy it from merchant A. However, Merchant A and B are selling at the same price for a unit value. In other words, Both Merchant A and B are selling 1kg of dry fertilizer for $1.

5 0
3 years ago
A dryer is shaped like a long semi-cylindrical duct of diameter 1.5 m. The base of the dryer is occupied with water-soaked mater
Anestetic [448]

Answer:

0.0371 kg/s.m

Explanation:

From the given information, let's have an imaginative view of the semi-cylinder; (The image is shown below)

Assuming the base surface of both ends of the cylinder is denoted by:

A_1  \ and   \ A_2

Thus, using the summation rule, the view factor F_{11 and F_{12 is as follows:

F_{11}+F_{12}=1

Let assume the surface (1) is flat, the F_{11} = 0

Now:

0+F_{12}=1

F_{12}=1

However, using the reciprocity rule to determine the view factor from the dome-shaped cylinder A_2 to the flat base surface A_1; we have:

A_2F_{21} = A_{1}F_{12} \\ \\ F_{21} = \dfrac{A_1}{A_2}F_{12}

Suppose, we replace DL for A_1 and

A_2 =  \dfrac{\pi D}{2}

Then:

F_{21} = \dfrac{DL}{(\dfrac{\pi D}{2}) L} \times 1 \\ \\  =\dfrac{2}{\pi} \\ \\  =0.64

Now, we need to employ the use of energy balance formula to the dryer.

i.e.

Q_{21} = Q_{evaporation}

But, before that;  let's find the radian heat exchange occurring among the dome and the flat base surface:

Q_{21}= F_{21} A_2 \sigma (T_2^4-T_1^4) \\ \\ Q_{21} = F_{21} \times \dfrac{\pi D}{2} \sigma (T_2^4 -T_1^4)

where;

\sigma = Stefan \ Boltzmann's \ constant

T_1 = base \ temperature

T_2 = temperature  \ of  \ the  \ dome

∴

Q_{21} = 0.64 \times (\dfrac{\pi}{2}\times 1.5) \times 5.67 \times 10^4 \times (1000^4 -370^4)\\ \\ Q_{21} = 83899.15 \ W/m

Recall the energy balance formula;

Q_{21} = Q_{evaporation}

where;

Q_{evaporation} = mh_{fg}

here;

h_{fg} = enthalpy of vaporization

m = the water mass flow rate

∴

83899.15 = m \times 2257 \times 10^3  \\ \\  m = \dfrac{83899.15}{ 2257 \times 10^3 }\\ \\ \mathbf{m = 0.0371 \ kg/s.m}

6 0
3 years ago
Other questions:
  • Please read
    6·1 answer
  • (Practice work, not graded)
    11·1 answer
  • Give two methods on how powder is produced in powder metallurgy.
    5·2 answers
  • A 26-tooth pinion rotating at a uniform 1800 rpm meshes with a 55-tooth gear in a spur gear reducer. Both pinion and gear are ma
    11·1 answer
  • The water of a 14’ × 48’ metal frame pool can drain from the pool through an opening at the side of the pool. The opening is abo
    13·1 answer
  • This is various straps secured on a worker to distribute the fall arrest forces. What is depicted in the image?
    6·2 answers
  • Which of the following best describes the basic purpose of the internet?
    7·2 answers
  • Find the remaining trigonometric function of 0 if
    13·1 answer
  • What do you think the top TWO game elements are that directly contribute to player immersion?
    15·1 answer
  • Why is personal development necessary based activity success life and career​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!