How to resolve the algorithm Middle three digits step by step in the Plain English programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Middle three digits step by step in the Plain English programming language
Table of Contents
Problem Statement
Write a function/procedure/subroutine that is called with an integer value and returns the middle three digits of the integer if possible or a clear indication of an error if this is not possible. Note: The order of the middle digits should be preserved. Your function should be tested with the following values; the first line should return valid answers, those of the second line should return clear indications of an error: Show your output on this page.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Middle three digits step by step in the Plain English programming language
Source code in the plain programming language
To run:
Start up.
Test 123.
Test 12345.
Test 1234567.
Test 987654321.
Test 10001.
Test -10001.
Test -123.
Test -100.
Test 100.
Test -12345.
Test 1.
Test 2.
Test -1.
Test -10.
Test 2002.
Test -2002.
Test 0.
Wait for the escape key.
Shut down.
To get the middle three digits of a number giving a string:
Privatize the number.
De-sign the number.
Convert the number to the string.
If the string's length is less than 3, put "Number has fewer than three digits" into the string; exit.
If the string's length is even, put "Number has no middle" into the string; exit.
Put the string's length divided by 2 into a midpoint number.
Slap a substring on the string.
Put the substring's first plus the midpoint minus 1 into the substring's first.
Put the substring's first plus 2 into the substring's last.
Put the substring into the string.
To test a number:
Get the middle three digits of the number giving a string.
Write "" then the number then " -> " then the string on the console.
You may also check:How to resolve the algorithm Factorial step by step in the Plain English programming language
You may also check:How to resolve the algorithm Averages/Arithmetic mean step by step in the Plain English programming language
You may also check:How to resolve the algorithm Leonardo numbers step by step in the Plain English programming language
You may also check:How to resolve the algorithm Zero to the zero power step by step in the Plain English programming language
You may also check:How to resolve the algorithm Fibonacci sequence step by step in the Plain English programming language