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 ________ is an area where you can position fields to use for filtering the PivotTable and thereby enabling you to display a
Studentka2010 [4]

Answer: FILTERS area

Explanation: PivotTable is the kind of a tool that is used for the calculation of the data by analyzing ,summarizing ,comparing it according to the pattern and the sequence of the data.In this this tool. filter is used as the component for the filtering of the data in small/minor unit by analyzing it deeply. Different filter techniques is used in analyzing of the spreadsheet in PivotTable.

3 0
3 years ago
The inability of BAE Automated Systems to create an automated baggage handling system led to a significant delay in the opening
Sergeu [11.5K]

Answer:

True

Explanation:

Airport was truly opened outside the city of Denver, because of the faults in BAE automated system.

6 0
3 years ago
How does microsoft label mac addresses in the windows utilities that show you the mac address?
statuscvo [17]

Based on computer analysis, Microsoft labels mac addresses in the windows utilities "<u>by showing the MAC address in the 'Physical Address' field."</u>

<h3>What is MAC Address?</h3>

MAC Address is the acronym for media access control address. A distinct identifier is allocated to a network interface controller (NIC).

MAC address is used as a network address in communications within a network component.

There are two ways to check for a MAC address in the Windows Utilities which is either through Command Prompt or Network Setting.

Hence, in this case, it is concluded that the correct answer is "<u>by showing the MAC address in the 'Physical Address' field."</u>

Learn more about MAC Address here: brainly.com/question/24812654

6 0
2 years ago
Na2CO3 → Na2O + what
Katarina [22]

Answer:

CO3

Explanation:

6 0
3 years ago
Read 2 more answers
What is the default text-wrapping option when inserting images into a Word document?
JulijaS [17]

Answer:

In line with the text

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • To move to the most extreme right cell containing data in your worksheet, what basic key combination can you use?
    7·1 answer
  • Software design and implementation are interleaved activities. The level of detail in the design depends on the type of system b
    5·1 answer
  • After configuring a static IP address on a desktop computer, the technician finds that he cannot communicate with other devices
    10·1 answer
  • Before using the data type string, the program must include the header file ____.
    6·1 answer
  • Suppose we provide a new implementation of the transport layer protocol tcp providing the same functionality using different alg
    14·1 answer
  • Identify the false statement.
    8·1 answer
  • What are some pros for having your phone during school hours?
    10·2 answers
  • in java Write a program with total change amount in pennies as an integer input, and output the change using the fewest coins, o
    13·1 answer
  • What is the component on the motherboard that confirms all devices are in working order once the computer is turned on?
    13·1 answer
  • Which type of loan is based on financial need
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!