Question
You are responsible for the development of an alphabetical string sorting program in C++. Your program should prompt the user to enter some words and
You are responsible for the development of an alphabetical string sorting program in C++. Your program should prompt the user to enter some words and then sort the words in alphabetical order and display them. Sort them alphabetically. You can also store the words entered by the user in an array of strings with predefined size or a dynamic array. Dynamically define the array also.
A sample run of your program should look like this:
Enter a word: laurie
Enter a word: dinesh
Enter a word: Erlich
Enter a word: Richard Enter a word: Jian
Enter a word: 0 Your sorted list is: dinesh Erlich Jian laurie Richard
? Store the words entered by the user in an array of strings (each element of the array is of type string).
? The maximum number of words for which the program needs to work must be set using the following constant (a global constant at the top of the program):
const int NUM_WORDS = 10; Then, throughout the program wherever this size is needed, the constant must be used rather than a literal number.
? You can assume that each word entered by the user will not contain any spaces.
? The program must stop prompting for further input if the maximum number of words is reached, or if the user enters "0" as one of the words. If the user enters "0" to end the input sequence, then the "0" must not be counted as one of the words sorted and later displayed.
? Sorting of the words must be done using a sorting method (Bubble Sort, Selection Sort or other). You are free to implement the sorting algorithm of your choice.
? The sorting method must be implemented in a function that takes as input an array of strings and the size (number of words) in the array. This function must sort the words from "smallest" to "largest" (you can use the compare function), which corresponds to alphabetical order if the strings are of letters.
? For true alphabetical sorting: you will have to account for upper- or lower-case letters. The upper-case and lower-case versions of a letter should be treated as if they are equals.
? Prompt the user for the number of words they would like to enter (no need to declare the constant NUM_WORDS).
? Dynamically allocate an array of strings (each element of the array is of type string) of that size.
? The program must stop prompting for further input once the maximum number of words is reached
? There is no need for the user to type "0" to indicate that they are finished. You have already asked them how many words they want to type, so that is how many words they will type.
Bubble Sort please.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started