Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 408 Weeks Ago, 1 Day Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Management Posted 02 Feb 2018 My Price 9.00

output sentence

i am unsure of how to delete the blank spaces & also read the next line?

Write a program that reads in a sentence of up to 100 characters and outputs the sentence with spacing corrected and with letters corrected for capitalization. In other words, in the output sentence, all strings of two or more blanks should be compressed to a single blank. The sentence should start with an uppercase letter but should contain no other uppercase letters. Do not worry about proper names; if their first letters are changed to lowercases, that is acceptable. Treat a line break as if it were a blank space, in the sense that a line break and any number of blank spaces are compressed to a single blank space. Assume that the sentence ends with a period and contains no other periods. For example, the input

   noW iS   thE    TiMe fOr aLl

         gOOD MEN TO ComE TO   tHe

   aId

oF

   ThE CounTRY.

should produce the output:

Now is the time for all good men to come to the aid of the country.

my code currently is


#include
#include
#include
using namespace std;
void firstletter(char[]);
void erasespaces(char[], int size);
void otherletters(char[]);

int main()
{
   int size = 100;
   char read[size];


   cout << "Please enter your input to be changed:";
   cin.getline(read, size);

   firstletter(read);
   erasespaces(read,size);
   otherletters(read);

   //cout << read;

   return 0;
}
void firstletter(char read[])
{
   int i = 0;
   if(read[i] != ' ')
   {
       read[i] = toupper(read[i]);
   }
}

void erasespaces(char read[], int size)
{
   bool space = false;
   for(int j = 0; j < strlen(read); j++)
   {
       if(read[j] != ' ')
       {
           cout << read[j];
           space = false;
       }
       else if(read[j] == ' ' && space == false)
       {
           space = true;
           cout << " ";
       }
   }

}
void otherletters(char read[])
{
   for(int k = 1; k < 100; k++)
   {
       read[k] = tolower(read[k]);
   }
}

Answers

(5)
Status NEW Posted 02 Feb 2018 10:02 PM My Price 9.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on-----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be-----------

Not Rated(0)