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

I need the following in my code: https://imgur.com/J1Xj5Wb Here is my code: #inc

ID: 3917346 • Letter: I

Question

I need the following in my code:

https://imgur.com/J1Xj5Wb

Here is my code:

#include

#include

#include

#include

// #include

using namespace std;

vector sttok(string str)

{

int i = 0;

vector res;

string temp = "";

for (i = 0; i < str.size(); i++)

{

if (str[i] == ' ')

{

res.push_back(temp);

temp = "";

}

else

{

temp.push_back(str[i]);

}

}

res.push_back(temp);

return res;

}

string strip(string str)

{

string res;

int i = 0;

while (i < str.size())

{

if (str[i] == ' ')

{

i++;

continue;

}

res.push_back(str[i]);

i++;

}

return res;

}

int main(void)

{

char framechar;

vector phrasetok;

cout << "press 1 if you want to enter phrase through keyboard and press 0 if "

"you want program to read phrase from file"

<< endl;

int in;

cin >> in;

std::string phrase;

cout << "enter the phrase you want to print"<

cin.ignore();

cin.clear();

if (in == 1) // reading from keyboard

{

getline(std::cin, phrase);

}

else // reading from a file

{

}

phrasetok = sttok(phrase);

cout << "Enter the printable frame character: ";

cin.clear();

cin >> framechar;

int just;

cout << "enter 1 for left justification, 2 for center justification and 3 "

"for right justification"

<< endl;

cin >> just;

int i = 0;

cout<<" ";

for (i = 1; i <=10; i++)

{

cout << framechar;

}

cout << endl;

i = 0;

while (i < phrasetok.size())

{

string str = phrasetok[i];

cout << framechar;

if (just == 1)

{

int sp = 10 - str.size()+1;

cout << str;

for (int j = 1; j < sp; j++)

{

cout << " ";

}

}

else if (just == 2)

{

int sp = 10 - str.size()+1;

sp = sp / 2;

for (int j = 1; j <= sp; j++)

{

cout << " ";

}

cout << str;

if(str.size()%2==0)

sp++;

for (int j = 1; j < sp; j++)

{

cout << " ";

}

}

else

{

int sp = 10 - str.size() +1;

for (int j = 1; j < sp; j++)

{

cout << " ";

}

cout << str;

}

cout<

i++;

}

cout<<" ";

for (i = 1; i <= 10; i++)

{

cout << framechar;

}

cout << endl;

return 0;

}

Explanation / Answer

#include <iostream>

#include <string>

#include <vector>

#include <cstring>

// #include

using namespace std;

vector<string> sttok(string str)

{

int i = 0;

vector<string> res;

string temp = "";

for (i = 0; i < str.size(); i++)

{

if (str[i] == ' ')

{

res.push_back(temp);

temp = "";

}

else

{

temp.push_back(str[i]);

}

}

res.push_back(temp);

return res;

}

string strip(string str)

{

string res;

int i = 0;

while (i < str.size())

{

if (str[i] == ' ')

{

i++;

continue;

}

res.push_back(str[i]);

i++;

}

return res;

}

int main(void)

{

char framechar;

vector<string> phrasetok;

cout << "press 1 if you want to enter phrase through keyboard and press 0 if "

"you want program to read phrase from file"

<< endl;

int in;

cin >> in;

std::string phrase;

cout << "enter the phrase you want to print"<<endl;

cin.ignore();

cin.clear();

if (in == 1) // reading from keyboard

{

getline(std::cin, phrase);

}

else // reading from a file

{

}

phrasetok = sttok(phrase);

cout << "Enter the printable frame character: ";

cin.clear();

cin >> framechar;

int just;

cout << "enter 1 for left justification, 2 for center justification and 3 "

"for right justification"

<< endl;

cin >> just;

int i = 0;

cout<<" ";

for (i = 1; i <=10; i++)

{

cout << framechar;

}

cout << endl;

i = 0;

while (i < phrasetok.size())

{

string str = phrasetok[i];

cout << framechar;

if (just == 1)

{

int sp = 10 - str.size()+1;

cout << str;

for (int j = 1; j < sp; j++)

{

cout << " ";

}

}

else if (just == 2)

{

int sp = 10 - str.size()+1;

sp = sp / 2;

for (int j = 1; j <= sp; j++)

{

cout << " ";

}

cout << str;

if(str.size()%2==0)

sp++;

for (int j = 1; j < sp; j++)

{

cout << " ";

}

}

else

{

int sp = 10 - str.size() +1;

for (int j = 1; j < sp; j++)

{

cout << " ";

}

cout << str;

}

cout<<framechar<<endl;

i++;

}

cout<<" ";

for (i = 1; i <= 10; i++)

{

cout << framechar;

}

cout << endl;

return 0;

}

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