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

I have written a program code that converts a sentence input by the user into lo

ID: 3621794 • Letter: I

Question

I have written a program code that converts a sentence input by the user into lowercase or uppercase according to the user choice.

The user can insert a sentence that can contain uppercase, lowercase, letters, blank spaces, digits, and symbols.

Problem: The program functions perfectly, but I don't know how to use the void convert(char*) in my program.

If user selects:

U(uppercase or lowercase): The program calls a user-defined function void convert_to_upper(char*) that accepts string pointer and coverts the full sentence to uppercase characters using the built-in function toupper(char).

 

L(uppercase or lowercase): The program calls a user-defined function void_convert_to_lower(char*) that accepts string pointer and converts the full sentence to lowercase characters using the built-in function tolower(char).

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

Output:

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

The code I wrote:

#include
using namespace std;

int main()
{

//Declaring variables. I named my string 'sentence'.
char sentence[100];
char option;

//string input
cout<<"Please insert the sentence:"<
cin.getline(sentence,100);

//option input
cout<
cout<<"Convert to [U]ppercase or [L]lowercase?"<
cin>>option;

//validate for lowercase
if (option=='L'||option=='l')
    {
        for(int i=0;sentence[i]!='';i++)
        {
        sentence[i] = tolower(sentence[i]);
        }
        cout<
        cout<<"The string after conversion is: "<<
    }

//validate for uppercase

if (option=='U'||option=='u')
    {
        for(int i=0;sentence[i]!='';i++)
        {
        sentence[i]=toupper(sentence[i]);
        }
        cout<
        cout<<"The string after conversion is: "<<
    }

return 0;
}

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

The thing im stuck on

I know i must include this part on the top

#include

void convert_to_upper(char*)

void convert_to_lower(char*)

 

I know i can use this, but not sure how to put it correctly in the code.

 

void convert_to_upper(char*sptr)

{

while (*sptr!='')

         {

            if (*sptr>='a' && *sptr<='z')

            *sptr=toupper(*sptr); //converts to uppercase

           ++sptr;

         }

 }

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

i really just need help in using the void convert(char*) part in my code, and dont understand weather to use a switch, while, or if statement.

 

Please help

i will give full carma points.

 

thank you :)

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

Explanation / Answer

Dear, Here is the code //Header file section #include using namespace std; //function prototypes void convert_to_upper(char *str) ; void convert_to_lower(char *str) ; int main() { char string[20]; char choice; //inputting string cout