Question
Question 2: Write a program that asks the user to enter n numbers, where n is the first thing specified by the user. The program
Question 2: Write a program that asks the user to enter n numbers, where n is the first thing specified by the user. The program then makes a list of the n numbers. Once the program finishes gathering the numbers in the list, the program should repeatedly do the following: ask the user for a number, then print the numbers in the list that are evenly divisible by that number. If the user enters 0, then the program should quit, before checking divisibility. Assume inputs are safe and all integers.
Note: Evenly divisible means that there is no remainder after division.
Program Hint: Use the Modulo Operator when checking evenly divisible. Consider how remainders relate to evenly divisible.
Design Hint:
Write a function that collects numbers
o Uses a loop and a list
o Returns a list
Write a function that takes a list and a number as a parameter
o Loops over the list checking even divisibility
o Collects the desired numbers in a list
o Returns a list
Write a function that continues to check divisibility until 0 is entered
o Calls other function to perform check
o Prints results of each check by calling the function that prints out matches
Write a function that outputs whether or not there were matches
o If matches found prints out matches.
Sample Output:
How many numbers do you want to check? 12
What is the price of this item: 5
What is the price of this item: 98
What is the price of this item: 4
What is the price of this item: 6
What is the price of this item: 35
What is the price of this item: 3
What is the price of this item: 36
What is the price of this item: 48
What is the price of this item: 24
What is the price of this item: 29
What is the price of this item: 33
What is the price of this item: 898
The number, which you want to find multiples of: 5
These numbers are multiples of 5:
5, 35
The number, which you want to find multiples of: 5000
None of the numbers are multiples of 5000
The number, which you want to find multiples of: 69
None of the numbers are multiples of 69
The number, which you want to find multiples of: 53
None of the numbers are multiples of 53
The number, which you want to find multiples of: 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started