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

#include using namespace std; #include int main() { cout << \"What is your first

ID: 3620562 • Letter: #

Question


#include
using namespace std;
#include



int main()
{
cout << "What is your first name? ";
string name;
cin >> name;
cout << "Nice to meet you " << name << ", my name is Spiffy Computer o. ";
cout << "I have been tasked with seeing how well you can write a sentence. ";
cout << "Please type a sentence. Hit enter when you are finished. ";
string sentence;
cin.get(); //used to remove the return line that is in buffer after entering name.
getline(cin,sentence);
while(sentence.size()<3)
{
cout << "Sorry " << name << ", but that is not good enough. Try again: ";
getline(cin,sentence);
}
cout << endl << "You typed:" << endl;
cout << sentence << endl;

int sent_length=sentence.size();

int correct=0;
if(sentence[0]>64 && sentence[0]<91) //make sure first letter is capitalized.
correct+=1;

if(sentence[sent_length-1]=='.' || sentence[sent_length-1]=='!' || sentence[sent_length-1]=='?')
//make sure sentence ends with punctuation.
correct+=2;

if(correct==0)
cout << "You didn't capitalize the first word of your sentence, or use punctuation! "
<< "I expected so much more from you " << name << "." << endl;

else if(correct<2)
cout << "Too cool to use punctuation eh " << name << "? ";

else if(correct<3)
cout << "You do know the first word in a sentence should be capitalized right, " << name << "? ";

else
cout << "Everything seems ok as far as I can tell, but I am only "
<< "programmed to check some basic sentence structure. ";

cout << "Your sentence has " << sent_length << " characters in it. ";

char spacebar= ' ';
int words=1;
for(int i = 0; i{
if(sentence[i]==spacebar)
words++;
}

cout << "Also, if I am not mistaken, your sentence has "
<< words << " word(s) in it. ";

cout << "Well " << name << ", I guess this is goodbye. I have no more "
<< "to offer. It has been fun. ";

saygoodbye();

getchar();
getchar();
return 0;


void saygoodbye()
{
cout << "Adios! ";
}

Explanation / Answer

please rate - thanks you're missing a prototype and a }, I also moved your using namspace to after the #includes- see the red #include <iostream>
#include <string>
using namespace std;
void saygoodbye();



int main()

{



cout << "What is your first name? ";

string name;

cin >> name;

cout << "Nice to meet you " << name << ", my name is Spiffy Computer #5. ";

cout << "I have been tasked with seeing how well you can write a sentence. ";

cout << "Please type a sentence. Hit enter when you are finished. ";

string sentence;

cin.get(); //used to remove the return line that is in buffer after entering name.

getline(cin,sentence);

while(sentence.size()<3)

{

cout << "Sorry " << name << ", but that is not good enough. Try again: ";

getline(cin,sentence);

}

cout << endl << "You typed:" << endl;

cout << sentence << endl;

int sent_length=sentence.size();

int correct=0;

if(sentence[0]>64 && sentence[0]<91) //make sure first letter is capitalized.

correct+=1;

if(sentence[sent_length-1]=='.' || sentence[sent_length-1]=='!' || sentence[sent_length-1]=='?')

//make sure sentence ends with punctuation.

correct+=2;

if(correct==0)

cout << "You didn't capitalize the first word of your sentence, or use punctuation! "

<< "I expected so much more from you " << name << "." << endl;

else if(correct<2)

cout << "Too cool to use punctuation eh " << name << "? ";

else if(correct<3)

cout << "You do know the first word in a sentence should be capitalized right, " << name << "? ";

else

cout << "Everything seems ok as far as I can tell, but I am only "

<< "programmed to check some basic sentence structure. ";

cout << "Your sentence has " << sent_length << " characters in it. ";

char spacebar= ' ';

int words=1;

for(int i = 0; i<sent_length; i++)

{

if(sentence[i]==spacebar)

words++;

}

cout << "Also, if I am not mistaken, your sentence has "

<< words << " word(s) in it. ";

cout << "Well " << name << ", I guess this is goodbye. I have no more "

<< "to offer. It has been fun. ";

saygoodbye();

getchar();

getchar();

return 0;
}
void saygoodbye()
{

cout << "Adios! ";

}