Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ask the user to input a matrix of any size. Ensure that the user inputs a positive, integer matrix (HINT: the any() function could help

Ask the user to input a matrix of any size. Ensure that the user inputs a positive, integer matrix (HINT: the any() function could help here). If there is an incorrect input, ask them for a matrix again. Ask the user if they want to 1) sum the prime numbers in the matrix 2) sum the odd numbers or 3) sum the even numbers.

Part 2: Summation of the matrix Once they choose, use a nested loop and conditionals to calculate the sum. You MUST use nested loops, vector math will not get credit.

Part 3: Output the sum Output the sum to the user, and ask them if they would like to do another calculation. If they say yes, show the menu again and ask for another choice (hint: use a while loop). If they say N, then stop the program.

Sample Output: This is a sample of what the program should show in the command window. If the user enters any information, it will be highlighted in RED:

EXAMPLE 1 Input a Matrix: [7 1 8; 4 5 8; 10 4 2] Please select from the following options:

1) Sum Prime Numbers

2) Sum Odd Numbers

3) Sum Even Numbers

The sum is 15 Would you like to do another calculation? Y/N: Y Please select from the following options: 1) Sum Prime Numbers 2) Sum Odd Numbers 3) Sum Even Numbers The sum is 13 Would you like to do another calculation? Y/N: Y Please select from the following options: 1) Sum Prime Numbers 2) Sum Odd Numbers 3) Sum Even Numbers The sum is 36 Would you like to do another calculation? Y/N: N Goodbye! Example 2 Input a Matrix: [7 1 8; 4 5 8; 10 4 2] Please select from the following options: 1) Sum Prime Numbers 2) Sum Odd Numbers 3) Sum Even Numbers Incorrect Input! Goodbye



Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Recommended Textbook for

Financial Reporting Financial Statement Analysis And Valuation A Strategic Perspective

Authors: James M. Wahlen, Stephen P. Baginski, Mark Bradshaw

9th Edition

1337614689, 1337614688, 9781337668262, 978-1337614689

Students also viewed these Programming questions