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
nordsb [41]
3 years ago
6

In this chapter, you saw an example of how to write an algorithm that determines whether a number is even or odd. Write a progra

m that generates 100 random numbers and keeps a count of how many of those random numbers are even, and how many of them are odd.]

Computers and Technology
2 answers:
vagabundo [1.1K]3 years ago
8 0

Answer:

// Program is written in Java Programming Language

// Comments are used for explanatory purpose

// Program starts here

public class RandomOddEve {

/** Main Method */

public static void main(String[] args) {

int[] nums = new int[100]; // Declare an array of 100 integers

// Store the counts of 100 random numbers

for (int i = 1; i <= 100; i++) {

nums[(int)(Math.random() * 10)]++;

}

int odd = 0, even = 0; // declare even and odd variables to 0, respectively

// Both variables will serve a counters

// Check for odd and even numbers

for(int I = 0; I<100; I++)

{

if (nums[I]%2 == 0) {// Even number.

even++;

}

else // Odd number.

{

odd++;

}

}

//.Print Results

System.out.print("Odd number = "+odd);

System.out.print("Even number = "+even);

}

yarga [219]3 years ago
3 0

Answer:

Complete python code along with comments to explain the whole code is given below.

Python Code with Explanation:

# import random module to use randint function

import random

# counter variables to store the number of even and odd numbers

even = 0

odd = 0

# list to store randomly generated numbers

random_num=[]

# A for loop is used to generate 100 random numbers

for i in range(100):

# generate a random number from 0 to 100 and append it to the list

   random_num.append(random.randint(0,100))

# check if ith number in the list is divisible by 2 then it is even

   if random_num[i] % 2==0:

# add one to the even counter

        even+=1

# if it is not even number then it must be an odd number

   else:

# add one to the odd counter

        odd+=1

# finally print the count number of even and odd numbers

print("Total Even Random Numbers are: ",even)

print("Total Odd Random Numbers are: ",odd)

Output:

Total Even Random Numbers are: 60

Total Odd Random Numbers are: 40

Total Even Random Numbers are: 54

Total Odd Random Numbers are: 46

You might be interested in
The purpose of this assignment is to determine a set of test cases knowing only the function’s specifications, reported hereaf
Nesterboy [21]

Answer:

The program is written using PYTHON SCRIPT below;

N=int(input(" Enter number of Rows you want:"))

M=[] # this for storing the matrix

for i in range(N):

l=list(map(int,input("Enter the "+str(i+1)+" Row :").split()))

M.append(l)

print("The 2D Matrix is:\n")

for i in range(N):

print(end="\t")

print(M[i])

W=[] # to store the first non zero elemnt index

T=[] # to store that value is positive or negative

L=len(M[0])

for i in range(N):

for j in range(L):

if (M[i][j]==0):

continue

else:

W.append(j) # If the value is non zero append that postion to position list(W)

if(M[i][j]>0): #For checking it is positive or negative

T.append(+1)

else:

T.append(-1)

break

print()

print("The first Non Zero element List [W] : ",end="")

print(W)

print("Positive or Negative List [T] : ",end="")

print(T)

Explanation:

In order for the program to determine a set of test cases it takes in input of 2D matrix in an N numbet of rows.

It goes ahead to program and find the column index of the first non-zero value for each row in the matrix A, and also determines if that non-zero value is positive or negative. The If - Else conditions are met accordingly in running the program.

5 0
3 years ago
What kind of software would you recommend a company use if its employees are receiving e-mails that are potentially hazardous ?
scZoUnD [109]

Answer:

Microsoft project

Explanation:

I'm smart

6 0
3 years ago
What is the safety for working ina facility that performs xrays?
mylen [45]

Hey and thanks for giving me the chance to serve u

For the nuclear industry, the NRC, amongst other things, dictates exposure limits to both workers dealing with radioactive material, called the occupationally exposed, and the general public, or non-occupationally exposed.  For an occupationally exposed worker, such as someone at a nuclear power plant or in nuclear medicine at a hospital (if they’re licensed by the NRC), the limit is 5 rem a year.  Surprisingly, while most nuclear power workers never receive anywhere close to that amount, some workers in the medical field, such as those working with X-ray fluoroscopy machines, are amongst the highest occupationally exposed workers.  Pregnant women who are occupationally exposed may choose to (but are not required to) declare their pregnancy and receive lower dose limits throughout the term of the pregnancy.

For members of the public, the annual limit from the NRC (which is matched by the EPA for areas not covered by NRC guidelines) is 100 mrem.  Licensed facilities have to have programs in place to limit exposure, and be able to demonstrate that procedures are in place that members of the public would not be exceeding those levels. 

7 0
3 years ago
Which html tag designates links to other web pages?.
Tcecarenko [31]

Answer:

<a href>

Explanation:

I found the answer on a Quizlet.

I hope this helps!

3 0
2 years ago
A software developer is busy writing code. What phase of the project life cycle is he in?
ra1l [238]

Answer:

project execution

Explanation:

According to project management, a project has been completed in 4 phases.

The first phase of the project cycle is project initiation, in which goal, objectives and completion time of the project has been decided. In second phase, requirements to accomplish the task and planning for completion of goals is completed. It is called Project Planning. Third phase is the execution phase, it is very important phase of the project, where developers and designers starts working on the code and other hardware designing. In this phase working on desired outputs has been completed according to the inputs. The last phase is project closure, In this phase the project is handed over to the client after completion for the testing.

So, Project Execution is the phase, where developers are busy in writing code.

4 0
3 years ago
Other questions:
  • Define a function begins_with_line that consumes a string and returns a boolean indicating whether the string begins with a dash
    15·1 answer
  • What type of restrictions may be placed on your license?
    7·1 answer
  • While you work on the customer's printer, he continues chatting about his network and problems he's been experiencing. One compl
    8·1 answer
  • When selecting text in word, holding down the ctrl key while clicking the mouse button will select the?
    15·1 answer
  • Hotels and motels that are part of a ________ share a centralized reservation system and a common image, logo or advertising slo
    7·1 answer
  • What is Administrator windows 10
    8·1 answer
  • Program Rock.java contains a skeleton for the game Rock, Paper, Scissors. Open it and save it to your directory. Add statements
    10·1 answer
  • The equation x + y2-4x+2y=b describes a circle.
    8·1 answer
  • Pda bkhhksejc pnwjoynelp dwo xaaj ajykzaz ywj ukq zaykza ep???<br><br><br> The Key Value is 22
    12·1 answer
  • Define a lambda function that accepts one argument (a list of strings) and returns a list of only the words that start with an '
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!