Asked by ????
Write a program that will ask a user 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 divisible by 3 or not. Continue doing this as many times as the user indicated. Once the loop ends, output how many numbers entered were divisible by 3 and how many were not divisible by 3.
Hint: For a number to be divisible by 3, when the number is divided by 3, 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 numbers divisible by 3 and numbers not divisible by 3.
Sample Run 1
How many numbers do you need to check? 5
Enter number: 20
20 is not divisible by 3.
Enter number: 33
33 is divisible by 3.
Enter number: 4
4 is not divisible by 3.
Enter number: 60
60 is divisible by 3.
Enter number: 8
8 is not divisible by 3.
You entered 2 number(s) that are divisible by 3.
You entered 3 number(s) that are not divisible by 3.
Sample Run 2
How many numbers do you need to check? 3
Enter number: 10
10 is not divisible by 3.
Enter number: 3
3 is divisible by 3.
Enter number: 400
400 is not divisible by 3.
You entered 1 number(s) that are divisible by 3.
You entered 2 number(s) that are not divisible by 3.
Benchmarks
Prompt the user to answer the question, “How many numbers do you need to check? “
Create and initialize two count variables - one for numbers divisible by 3 and one for numbers not divisible by 3.
Based on the previous input, create a for loop that will run that exact number of times.
Prompt the user to "Enter number: "
If that number is divisible by 3, output “[number] is divisible by 3.”
Update the appropriate count variable.
Or else if the number is not divisible by 3, output “[number] is not divisible by 3.”
Update the appropriate count variable.
Output “You entered [number] number(s) that are divisible by 3.”
Output “You entered [number] number(s) that are not divisible by 3.”
Hint: For a number to be divisible by 3, when the number is divided by 3, 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 numbers divisible by 3 and numbers not divisible by 3.
Sample Run 1
How many numbers do you need to check? 5
Enter number: 20
20 is not divisible by 3.
Enter number: 33
33 is divisible by 3.
Enter number: 4
4 is not divisible by 3.
Enter number: 60
60 is divisible by 3.
Enter number: 8
8 is not divisible by 3.
You entered 2 number(s) that are divisible by 3.
You entered 3 number(s) that are not divisible by 3.
Sample Run 2
How many numbers do you need to check? 3
Enter number: 10
10 is not divisible by 3.
Enter number: 3
3 is divisible by 3.
Enter number: 400
400 is not divisible by 3.
You entered 1 number(s) that are divisible by 3.
You entered 2 number(s) that are not divisible by 3.
Benchmarks
Prompt the user to answer the question, “How many numbers do you need to check? “
Create and initialize two count variables - one for numbers divisible by 3 and one for numbers not divisible by 3.
Based on the previous input, create a for loop that will run that exact number of times.
Prompt the user to "Enter number: "
If that number is divisible by 3, output “[number] is divisible by 3.”
Update the appropriate count variable.
Or else if the number is not divisible by 3, output “[number] is not divisible by 3.”
Update the appropriate count variable.
Output “You entered [number] number(s) that are divisible by 3.”
Output “You entered [number] number(s) that are not divisible by 3.”
Answers
There are no human answers yet.
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.