subject
Computers and Technology, 24.02.2021 21:10 anyar

Assignment 4: Evens and Odds Instructions

Write a program that will ask a user for how many numbers they would like to check. Then, using a for loop, prompt the user for a number, and output if that number is even or odd. Continue doing this as many times as the user indicated. Once the loop ends, output how many even numbers were entered and how many odd numbers were entered.

Hint: For a number to be even, when the number is divided by 2, there should be no remainder - so you will want to use the modulus (%) operator.

Hint: You will need two count variables to keep track of odd and even numbers.

Sample Run 1
How many numbers do you need to check? 5
Enter number: 20
20 is an even number.
Enter number: 33
33 is an odd number.
Enter number: 4
4 is an even number.
Enter number: 77
77 is an odd number.
Enter number: 8
8 is an even number.
You entered 3 even number(s).
You entered 2 odd number(s).
Sample Run 2
How many numbers do you need to check? 3
Enter number: 10
10 is an even number.
Enter number: 3
3 is an odd number.
Enter number: 400
You entered 2 even number(s).
You entered 1 odd number(s).

Sample Run 2
How many numbers do you need to check? 3
Enter number: 10
10 is an even number.
Enter number: 3
3 is an odd number.
Enter number: 400
You entered 2 even number(s).
You entered 1 odd number(s).

Benchmarks
1. Create and initialize two count variables - one for odd and one for even.
2. Prompt the user to answer the question, “How many numbers do you need to check?"
3. Based on the previous input, create a for loop that will run that exact number of times.
1. Prompt the user to “Enter number: “
2.If that number is even, output “[number] is an even number.”
3.Update the even count variable.
4.Or else if the number is odd, output “[number] is an odd number.”
5.Update the odd count variable.
4.Output “You entered [number] even number(s).”
5.Output “You entered [number] odd number(s)."

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:30
Exchanging which type of data uses the least bandwidth? music photographs video voice bandwidth- the amount of data that can be moved between two points in a set time period
Answers: 1
question
Computers and Technology, 22.06.2019 12:30
Some of the first computer games were created in the early 1970s by college students experimenting after hours to see what the were capable of doing.
Answers: 3
question
Computers and Technology, 24.06.2019 01:30
Suppose a cpu with a write-through, write-allocate cache achieves a cpi of 2. what are the read and write bandwidths (measured by bytes per cycle) between ram and the cache? (assume each miss generates a request for one block.)
Answers: 1
question
Computers and Technology, 24.06.2019 18:20
The following if statement contains a logic error, not a syntax error. rewrite it so that it is correct. assume the variable age already exists and holds a valid number. if (age == 18 & & age == 19) {
Answers: 1
You know the right answer?
Assignment 4: Evens and Odds Instructions

Write a program that will ask a user for how...
Questions
question
Mathematics, 20.05.2020 22:04
question
Mathematics, 20.05.2020 22:04
question
Mathematics, 20.05.2020 22:04
question
Arts, 20.05.2020 22:04
question
Mathematics, 20.05.2020 22:04
question
History, 20.05.2020 22:05