Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code Debugging Given code for two programming challenges, find the mistakes that prevent it from working! Key programming concepts: Common programming mistakes Approrimate lines of

image text in transcribed
image text in transcribed
image text in transcribed
Code Debugging Given code for two programming challenges, find the mistakes that prevent it from working! Key programming concepts: Common programming mistakes Approrimate lines of code: The code is already written! Assignment Details: For this homework you must fix the code provided, NOT write your own code! For each error/typo/bug that you find, add a comment explaining what you fixed (the comments can be short and simple). You will turn in the fixes and corresponding comments as your homework solution to Canvas Here are a few guidelies to follow You can not simply rewrite the code yourself .Avoid deleting chunks of code; the code does work except for the typos/mistakes Avoid adding several lines of new code; the main functionality is already written . Each line may have a typo, logic mistake, missing code piece, may be in the wrong location, etc... Leave a comment with a short explanation of the error near the line the mistake was found Lowest multiple with 9s and 0s clc; clear; N = input ('Enter a positive whole number N: ', 's'); cnt1; while true M = N*cnt ; while M1 remaindermod (10,M); if remainder 9 | remainder 0 else end continue; M floor(H* 10 ) ; end break; end cnt+1; end fprintf( 'Lowest multiple with only 9s and 0s: %d ',N) Challenge B. Given a positive integer N, find the lowest multiple of N made up of only 9's and O's! Program Inputs .Enter a positive whole number N - The user will always follow instructions, no error checking needed! Program Outputs Lowest multiple with only 9s and 0s: XXx. - Replace XXX with the lowest multiple found Solution Process Ask the user for N Repeatedly create a multiple of N and test if all digits are 9 or 0: - Create the next multiple of N, called M Repeatedly divide M by 10 to check each digit: s Check the remainder when dividing M by 10 s If the remainder is 9 or 0, reduce M by a factor of 10 (ignore any decimals) If the remainder was another number, try the next multiple of N Test Case 1: Enter a positive whole number N: 5 Lovest multiple with only 9s and 0s: 90 Test Case 2: Enter a positive whole number N: 6 Lovest multiple with only 9s and 0s: 90 Test Case 3: Enter a Lovest multiple with only 9s and 0s: 9009 positive whole number N: 7 Test Case 4: Enter a positive whole number N: 432 Lovest multiple with only 9s and 0s: 9990000 Test Case 5: Enter a positive whole number N: 511 Lovest multiple with only 9s and Os: 90099009 Code Debugging Given code for two programming challenges, find the mistakes that prevent it from working! Key programming concepts: Common programming mistakes Approrimate lines of code: The code is already written! Assignment Details: For this homework you must fix the code provided, NOT write your own code! For each error/typo/bug that you find, add a comment explaining what you fixed (the comments can be short and simple). You will turn in the fixes and corresponding comments as your homework solution to Canvas Here are a few guidelies to follow You can not simply rewrite the code yourself .Avoid deleting chunks of code; the code does work except for the typos/mistakes Avoid adding several lines of new code; the main functionality is already written . Each line may have a typo, logic mistake, missing code piece, may be in the wrong location, etc... Leave a comment with a short explanation of the error near the line the mistake was found Lowest multiple with 9s and 0s clc; clear; N = input ('Enter a positive whole number N: ', 's'); cnt1; while true M = N*cnt ; while M1 remaindermod (10,M); if remainder 9 | remainder 0 else end continue; M floor(H* 10 ) ; end break; end cnt+1; end fprintf( 'Lowest multiple with only 9s and 0s: %d ',N) Challenge B. Given a positive integer N, find the lowest multiple of N made up of only 9's and O's! Program Inputs .Enter a positive whole number N - The user will always follow instructions, no error checking needed! Program Outputs Lowest multiple with only 9s and 0s: XXx. - Replace XXX with the lowest multiple found Solution Process Ask the user for N Repeatedly create a multiple of N and test if all digits are 9 or 0: - Create the next multiple of N, called M Repeatedly divide M by 10 to check each digit: s Check the remainder when dividing M by 10 s If the remainder is 9 or 0, reduce M by a factor of 10 (ignore any decimals) If the remainder was another number, try the next multiple of N Test Case 1: Enter a positive whole number N: 5 Lovest multiple with only 9s and 0s: 90 Test Case 2: Enter a positive whole number N: 6 Lovest multiple with only 9s and 0s: 90 Test Case 3: Enter a Lovest multiple with only 9s and 0s: 9009 positive whole number N: 7 Test Case 4: Enter a positive whole number N: 432 Lovest multiple with only 9s and 0s: 9990000 Test Case 5: Enter a positive whole number N: 511 Lovest multiple with only 9s and Os: 90099009

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

Recommended Textbook for

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

What is IUPAC system? Name organic compounds using IUPAC system.

Answered: 1 week ago

Question

What happens when carbonate and hydrogen react with carbonate?

Answered: 1 week ago

Question

=+4 How does one acquire a global mindset?

Answered: 1 week ago

Question

=+2 How can the effectiveness of global virtual teams be improved?

Answered: 1 week ago