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

Wrapper classes, Character testing andconversion, String objects, StringBuilder,

ID: 3616463 • Letter: W

Question

Wrapper classes, Character testing andconversion, String objects, StringBuilder, Tokenizing Strings

In this exercise, we start text processing using string objectsand tokenizers, and explore wrapper classes, also. I need helpwriting a method that accepts a String object anddisplays its contents backward. Forinstance, if the string is “gravity” the method shoulddisplay “ytivarg”. I need to demonstrate the method ina program that asks the user to input a string and then passes itto the method. (Any explanations also appreciated)

Explanation / Answer

#inlcude<iostream.h>
#include<conio.h>

void backward(char[] a);

int main()
{
clrscr();
char array[20];
cout<<"Enter a word";
cin>>array;
cout<<" Word before Processing..."<<array;
backward(array);
cout<<" Word after processing..."<<array;
getch();
return 0;
}
void backward(char a[])
{
char b[20];
int v=0;
int count=0;
for(;a[v]!='';v++)
count++;
int index=0;
for(v=count;v>=0;v--)
{
b[index]=a[v];
index++;
}
b[index]='';
for(v=0;b[v]!='';v++)
a[v]=b[v];

a[index]='';
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote