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]
4 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]4 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]4 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
Which of the following rights is NOT guaranteed by copyright?
sleet_krkn [62]

Answer:

A. Right to avoid criticism

Explanation:

Patent can be defined as the exclusive or sole right granted to an inventor by a sovereign authority such as a government, which enables him or her to manufacture, use, or sell an invention for a specific period of time.

Generally, patents are used on innovation for products that are manufactured through the application of various technologies.

Basically, the three (3) main ways to protect an intellectual property is to employ the use of

I. Trademarks.

II. Patents.

III. Copyright.

Copyright law can be defined as a set of formal rules granted by a government to protect an intellectual property by giving the owner an exclusive right to use while preventing any unauthorized access, use or duplication by others.

Hence, the right that is not guaranteed by copyright laws is the right to avoid criticism because as an author or writer your literary work is subject to criticism from the readers and by extension the general public.

4 0
3 years ago
What questions do they ask for the 08.03 Discussion- Based Assesment in Drivers Ed?? Thanks.
mel-nik [20]

When should my headlights be turned on?

Why shouldn't one take medication before driving?

Why must you use a turn signal?

I'm not sure about that last one because I forgot but I think its right.

6 0
4 years ago
Randy earn $22 per hour. This is an example of
ra1l [238]

Answer:

I am confused what the question is asking, but I am guessing what $22 per hour means? He earns $22 for every hour he works or does something.

So this hourly wage?  

Wage is the answer you are looking for.

8 0
3 years ago
What lists the parts of the report and the pages they are on?
Bezzdna [24]

Answer:

Table of Contents

Explanation:

The list at which all the titles of chapters, and different parts of reports such as diagrams, pictures, tables, and headings along with their page numbers is called table of contents.

7 0
3 years ago
12. In Justify the text is aligned both to the right and to the left margins, adding extra space between words as necessary *
Lena [83]

\blue{

\green{

Answer:

  • False

Explanation:

  • Because, aligment the tex are aligned in the centre of the page.

\pink{

\red{

4 0
3 years ago
Read 2 more answers
Other questions:
  • (PLS HELP 99 POINTS) In a paragraph of no less than 125 words, explain the three aspects involved in gaining a true appreciation
    14·2 answers
  • Jim has excellent oral and written communication skills. He enjoys public speaking and wants a job in which he will interact wit
    10·2 answers
  • When should an individual consider entering parenthood?
    5·1 answer
  • A dictionary password attack is a type of attack in which one person, program, or computer disguises itself as another person, p
    5·1 answer
  • A Windows user has been successfully saving documents to the file server all morning. However, the latest attempt resulted in th
    9·2 answers
  • Do you watch markiplier?
    13·2 answers
  • Which phrases/sentence correctly describe the use of bitmap images?
    8·1 answer
  • In order to print multiple worksheets, what needs to happen before printing?
    14·1 answer
  • Best company who provides the best ISP (internet service provider)?
    13·1 answer
  • Who is primarily responsible for ensuring cybersecurity in society? Select 3 options.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!