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
Write the code for invoking a method named sendObject. There is one argument for this method which is of type Customer. Assume t
kodGreya [7K]

Answer:

sendObject(John_Doe);

Explanation:

The above code has been written in Java.

Since the calling class is the same that declares it, to invoke the method, simply call its name with its argument(s) in a pair parentheses. The name of the method is "sendObject" and its argument is a reference to an object of type Customer saved in a variable called "John_Doe". This can be written as follows:

sendObject(John_Doe);

Hope this helps!

3 0
3 years ago
To insert a new slide, which tab option should you select?
jek_recluse [69]

Ithink that the answer is C)

4 0
3 years ago
Read 2 more answers
Assignment
Lena [83]

Answer:

it

is

not

a

big

question

it

is

so

simple

5 0
3 years ago
A maxillary partial denture will have a ____ connector, and the mandibular partial denture will have a ____ connector.
spayn [35]

The answer to the maxillary partial denture and the mandibular partial denture respectively are; Palatal connector and Lingual Connector

<h3>Understanding Dental Health</h3>

Maxillary partial denture is a dental prosthetic that allows for the placement of a series of artificial teeth in an area in the upper jaws where healthy teeth used to exist.

Meanwhile, Mandibular Partial Denture is a dental prosthetic that allows for the placement of a series of artificial teeth in an area in the lower jaws where healthy teeth used to exist.

Now, a maxillary partial denture has a palatal connector while a mandibular partial denture has a lingual connector.

Read more about dental health at; brainly.com/question/24345244

8 0
2 years ago
Explain block diagram of. computer architure​
ozzi

Answer:

A block diagram is a diagram of a system in which the principal parts or functions are represented by blocks connected by lines that show the relationships of the blocks. They are heavily used in engineering in hardware design, electronic design, software design, and process flow diagrams.

Explanation:

In your question you asked architure but maybe it is architecture (•;

5 0
2 years ago
Other questions:
  • You have no control over who views your social network information
    13·2 answers
  • A program that interacts with another piece of software as it if were a human user is known as a(n) ________.
    5·1 answer
  • A restaurant has a case type that allows customer to book the dining room for events. Customers provide basic information includ
    7·1 answer
  • Moderate changes to existing processes falls under the _________ analysis. Business Process Automation (BPA) Business Process Im
    5·1 answer
  • What can you find the under the privacy policy section of a shopping website?
    12·1 answer
  • What development first helped people shape their communities through<br> informed decisions?
    5·1 answer
  • Which of these statements about the truck driving occupation in the U.S. are accurate?
    12·2 answers
  • Computer application just help me with it all ?
    8·1 answer
  • Disuss the roles of hardware,software and databases in regard to computer based information systems
    7·1 answer
  • I will give brainyest
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!