Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this exercise, use the following 2 D list, which is already declared and initialized in your programming environment below. 3 4 3 8 5

For this exercise, use the following 2D list, which is already declared and initialized in your programming environment below.
3438504439
4236404344
2431464045
4347353126
3728203650
Your task is to determine whether each item in the list above is divisible by 5 or not. If an item is divisible by 5, then leave that value as-is in the list, but if it is not divisible by 5, then replace that value in the list with a 0. Remember that you will need to use modular division from Unit 2 to determine if a value is divisible by 5. Finally, print out the list in the format as seen in the sample run below.
Note: Be sure that your program accounts for 2D lists of any size, not just lists that are 5 x 5. Your program will be tested against lists of size n by n. It should work for any square 2D list, not just the one shown. You should also use for loops in your program, not while loops.
Sample Run
005000
004000
0004045
003500
0020050

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions