Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

lut prompt the user for input during the execution of your program. Write a prog

ID: 3696280 • Letter: L

Question

lut prompt the user for input during the execution of your program. Write a program named Lab3.cpp. The program should satisfy the requirements specified in chapter 10, program challenge Capitalizer with the following exceptions: instead of asking the user to input a string following string: in chapter 10, program challenge #5. Sentence and passing it to the function, initialize the C-string with t in advance. besides, it's expensive, and I don't have any money "no, not tonight. it's a very popular place and you have to make reservations in advance. besides, it's expensive, and The modified string should look like: No, not tonight. It's a very popular place and you have to make reservations in ad ar place and you have to make reservations in advance. Besides, it's expensive, and I don't have any money The punctuation marks that signal the end of a sentence are the period, the question mark and the ex clamation mark So your code should work with sentences that end with the question mark and the exclamation mark too. Yes, your program needs to include the main function that prepares the C-string and call s the function as written there in the book Display the text before and after the call. The output of your program The text before the no, not tonight. Its a very popular place and you have to make reservations in advance. should look something like the following: besides, it's expensive, and I don't have any money

Explanation / Answer

/**
C++ program that converts user given text each sentence in the text starts
with capital letter. Print the user text before and after conversion.
*/
//header files
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
//function prototype
void sentenceCapitalizer(char *text);
int main()
{

   char userString[]="no , not tonight.it's a very popular place and you have to make reservations in advance. besides, it's expensive, and i don't have any money.";
   cout<<"The text before the modfication:"<<endl;
   cout<<userString;

   cout<<endl;
   sentenceCapitalizer(userString);
   cout<<"The text after the modfication:"<<endl;
   cout<<userString<<endl;


   system("pause");
   return 0;
}

/**
The function sentenceCapitalizer that takes a character c-string as input
text and converts the text of starting letter of sentence is capital.
*/
void sentenceCapitalizer(char *text)
{
   //convert the first letter to capital
   text[0]=toupper(text[0]);
   //convert the starting letter of of sentence to capital
   for(int index=1;text[index]!='';index++)
   {
       //check if character is full stop
       if(text[index]=='.')
       {
           //chceck if the next is space continue until next is not space
           while(text[++index]==' ')
               continue;
           //convert the character letter to capital
           text[index]=toupper(text[index]);          
       }
   }
}


------------------------------------------------------------------------------------------------

Sample output:

The text before the modfication:
no , not tonight.it's a very popular place and you have to make reservations in
advance. besides, it's expensive, and i don't have any money.
The text after the modfication:
No , not tonight.It's a very popular place and you have to make reservations in
advance. Besides, it's expensive, and i don't have any money.