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 a program which prompts the user for a celsius temperature, convert the temperature to fahrenheit, and print out the conve
JulsSmile [24]

print("——OR——") Input ("Temperature value in degree Celsius:"), celsius 2 = float) Celsius 2 = (Fahrenheit 2 * 9/5) + 32; print the result.

The user's input is taken. Enter the temperature in celsius by typing it into the input box. Fahrenheit is equivalent to (celsius multiplied by 1.8) + 32 print(str(celsius)+ "A degree in Celsius is equal to a " + str(fahrenheit)+ " degree in Fahrenheit. The change from C to F is therefore 100/180, or 5/9. It is 180/100 or 9/5 from F to C. As a result, the conversion yields °F = °C (9/5) + 32. As a result, the equation for changing from the Celsius to Fahrenheit scale becomes °F = °C (9/5) + 32. To convert from degrees Fahrenheit to degrees Celsius, do the inverse calculation: subtract 30 from the degrees Fahrenheit reading, then multiply the result by two to obtain the degrees Celsius reading.

Learn more about conversion here-

brainly.com/question/13163755

#SPJ4

6 0
11 months ago
The act of illegally copying software, music,or movies that are copied protect?
miv72 [106K]
It’s protects piracy C
4 0
3 years ago
Read 2 more answers
What is the difference between an html opening tag and a closing tag?.
Doss [256]

Answer:

Explanation:

Generally speaking, there are two kinds of tags - opening tags: <html> and closing tags: </html>. The only difference between an opening tag and a closing tag is the forward slash "/". You label content by putting it between an opening tag and a closing tag.

HTML is all about elements.

7 0
1 year ago
Write a program that reads a list of integers into a list as long as the integers are greater than zero, then outputs the smalle
almond37 [142]

Answer:

Check the explanation

Explanation:

10

5

3

21

2

-6

the output will be somthing like this:

2 21

You can then suppose that the list of integers will contain at least 2 values.

4 0
3 years ago
Complete the statement by entering the appropriate term in the space below.
Vera_Pavlovna [14]

Answer:

Probably "compress", but these days the common answer is "upload to cloud".

Explanation:

Compressing the files is an easy way to reduce their size, unless most of the size is in already compressed, high-entropy formats (like mp3, jpeg or mp4).

The common compression format is .ZIP - you've probably seen it countless times, but other ways like RAR, 7Z are also popular, while Linux users mostly deal with tar.gz, tar.bz2 or tar.xz

On the other hand, the standard practice these days is to upload the presentation to a cloud service, like GSheets or Office PowerPoint 365, which gets rid of the limits of email filesize, while providing a convenient web-app way to view the presentation without downloading (and it doesn't clutter their inbox space or hard drives)! Alternatively, one other way to email any large file (not just a presentation) includes uploading it to some service like DropBox, GDrive or anything similar.

7 0
2 years ago
Read 2 more answers
Other questions:
  • Which of the following is not a common network architecture type?
    9·1 answer
  • Which date formats are allowed in Excel for February 14, 2018? Check all that apply.
    15·2 answers
  • What is the purpose of exporting your public key to the directory services server?
    11·1 answer
  • Which option is used to apply formatting to multiple objects on a single slide while still maintaining the ability to manage the
    14·2 answers
  • How do I learn coding? Python
    5·2 answers
  • How to determine the critical crack size for a<br> plate
    15·1 answer
  • 45 points!!
    15·2 answers
  • 1 point
    13·1 answer
  • Explain how communication facilitate cordination​
    14·1 answer
  • Why is the computer uses binary why not trinary?​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!