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
You have been using the same computer for several years. To extend its service life, you decide to upgrade the processor. You ch
mestny [16]

Answer:

Option B i.e., Update the UEFI firmware.

Explanation:

The user had many periods of using the same machine. He wants to update the processor to increase the existing service period. Later, he tests the paperwork onto the motherboard and buys the best motherboard-supported processor.  

While the user starts the machine, though, that makes a noise constantly, nothing is shown on its monitor and it wouldn't start. So, the first step is he will update firmware from UEFI.

Thus, the other options are not correct according to the scenario.

6 0
4 years ago
A key or combination of keys that complete an action more efficiently than using the mouse is called a(n) keyboard shortcut.
andreev551 [17]
The answer to your question is true
6 0
3 years ago
If your cousin wanted to view information from the world wide web, what application software would you tell her to be sure she h
MAVERICK [17]
Well, I would say a web browser, like Mozilla Firefox, Safari for IOS, Windows Edge, Chrome, or Internet Explorer; and some anti-malware software, since there are multiple websites on the WWW that try to steal your information and give your device viruses.
6 0
3 years ago
What is the least number of options you should come up with to help you solve a problem?
Lubov Fominskaja [6]

Answer:

Comparing
Whole
Numbers

Symbols
are
used
to
show
how
the
size
of
one
number
compares
to
another.


These
symbols
are
<
(less
than),
>
(greater
than),
and
=
(equals).

For
example,
since
2
is
smaller
than
4
and
4
is
larger
than
2,
we
can
write:
2
<
4,
which


says
the
same
as
4
>
2
and
of
course,
4
=
4.


• To
compare
two
whole
numbers,
first
put
them
in
numeral
form.


• The
number
with
more
digits
is
greater
than
the
other.


• If
they
have
the
same
number
of
digits,
compare
the
digits
in
the
highest
place
value


position
(the
leftmost
digit
of
each
number).
The
one
having
the
larger
digit
is

greater
than
the
other.


• If
those
digits
are
the
same,
compare
the
next
pair
of
digits
(look
at
the
numbers
to


the
right).


• Repeat
this
until
the
pair
of
digits
is
different.
The
number
with
the
larger
digit
is


greater
than
the
other.


Example:
402
has
more
digits
than
42,
so
402
>
42.


Example:
402
and
412
have
the
same
number
of
digits.


We
compare
the
leftmost
digit
of
each
number:
4
in
each
case.


Moving
to
the
right,
we
compare
the
next
two
numbers:
0
and
1.


Since
zero
is
less
than
one,
402
is
less
than
412
or
402<412.

Explanation:

8 0
3 years ago
True / False
Tju [1.3M]

Answer:

TRUE, The PC is always incremented by the same amount in fixed-length instruction set architectures.

Explanation:

Its TRUE that Program Counter ( PC ) is always incremented by the same amount in fixed - length instruction set architectures ( fixed length ISA) . As the instruction set length is fixed in fixed - length instruction set architectures, the Program Counter to fetch the next instruction set it has to be incremented by fixed length. This fixed length depends on the hardware of the architecture (the number of bytes each machine word contains and number of machine words per memory location)

7 0
4 years ago
Other questions:
  • An independent frame that holds a program, document, or folder contents in windows 7 is called a ____.
    11·1 answer
  • Can you help please.
    11·1 answer
  • What is a close-up shot, and when it is an appropriate shot choice in a film?
    6·1 answer
  • Which question best helps a reader understand a plot’s exposition? What will life be like after the character takes action? How
    14·2 answers
  • Does anyone know how to cancel a Pandora Free Trial Subscription? I need to cancel it by tomorrow. Please help!
    12·1 answer
  • 3. By default, Blender® remembers your last 32 actions and allows you to undo them one at a time by pressing CTRL+Z. (1 point)
    9·1 answer
  • C++ Proagram
    7·1 answer
  • I need help. I wanna help a friend by giving him my powerpoint but I dont want him to steal my work. Is their anyway to restrict
    8·1 answer
  • David Griffin on How Photography Connects Us
    11·1 answer
  • When using a self-contained recovery device on a cfc, hcfc, or hfc system with an operating compressor, technicians must?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!