#include #include class Exchange { public: string sent, rev; int size = 0; Exchange(); void readsentence(); void exfirstlast(); void display(); Exchange::Exchange() { sent = L""; rev = L""; size = 0; } void Exchange::readsentence() { cout <<"Enter a sentence : "; sent = readLine(); size = sent.length(); if (sent[size-1] != '.') sent = sent + L"."; size = size+1; } void Exchange::exfirstlast() { string s1 = L""; wchar_t ch; for (int i = 0;i < size;i++) { ch = sent[i]; if (ch != L' ' && ch != L'.') { s1 = s1 + StringHelper::toString(ch); } else { int l = s1.length(); for (int j = 0;j < l;j++) { if (j == 0) { ch = s1[l - 1]; } else if (j == (l - 1)) { ch = s1[0]; } else { ch = s1[j]; } rev = rev + String(ch); } rev = rev + L" "; s1 = L""; } } } void Exchange::display() { cout <<"The Original Sentence is : " << sent < &args) throw(IOException) { Exchange *ob = new Exchange(); ob->readsentence(); ob->exfirstlast(); ob->display(); }