how to write algorithm in isc computer??
Answers
Answer:
Algorithm for main() method :
Step 1 : Start of algotithm
Step 2 : Input the sentence and store it in a String variable ‘s’
Step 3 : Convert the sentence into upper case
Step 4 : Create a StringTokenizer object ‘str’ to extract tokens (words) from the sentence using space and other the punctuation marks namely ‘.’, ‘?’, ‘!’
Step 5 : Count the number of tokens (words) and store it in an integer variable ‘c’. Also create a String array word[ ] of size ‘c’
Step 6 : Start a for loop from i = 0 to less than ‘c’ and store the tokens of the sentence into the word [ ] array
Step 7 : Declare an integer variable ‘count’ and initialize it with 0
Step 8 : Start a for loop from i = 0 to less than ‘c’ and repeat step 9
Step 9 : Call the function isPalin() as : ob.isPalin(word[i]). If the returned value is ‘true’ then increase the count variable and print the word.
Step 10 : If count of palindromic words is not equal to zero, then print the value stored in the variable ‘count’
Step 11 : End of algorithm for main() method
Algorithm for function boolean isPalin(String s) :
Step 1 : Start of algorithm for function isPalin()
Step 2 : Find the length of the String ‘s and store it in an integer variable ‘l’
Step 3 : Declare and initialize a String variable rev=”” for storing the reverse of the String ‘s’
Step 4 : Start a reverse for loop from i = l-1 to 0 and repeat step 5
Step 5 : Extract characters from the end of the original string and add them to the variable ‘rev’
Step 6 : If the reverse word obtained (rev) is equal to the original String (s), then return true, otherwise return false.
Step 7 : End of algorithm for the function isPalin().
Similarly if you have more functions, then just write their algorithms in a similar fashion one after the other.
Answer:
Hlo rimi why are you leaving brainly