NOTE: ONE input line contains a string of tokens.
MULTIPLE output lines containing one or more tokens.
Definition: A "token" is a sequence of characters surrounded by whitespace.
"Whitespace" is a blank/space, tab, blank line or end-of-line.
Example: The phrase, "The slow, fat, dog is pretty!" contains tokens
The
slow,
fat,
dog
is
pretty!
----------------------------------------------------------------------------
PART I. READING & WRITING TOKENS.
----------------------------------------------------------------------------
Algorithm:
1. Prompt user to enter ONE sentence containing at least six (6) tokens.
2. Read six tokens into string variables tok1, tok2, ..., tok6.
3. Output the six tokens, one per line, numbered, in the format:
Required output format
-----------------------
1: token1 1: The
2: token2 2: slow,
...
6: token6 6: pretty!
4. Output the six tokens, two per line that begins with the '|' (vertical
bar) character; each token preceded by ONE tab.
Required output format
------------------
| token1 token2 | The slow,
| token3 token4 | fat, dog
| token5 token6 | is pretty!
5. Output the six tokens, three per line. Each line begins with the '>'
character, followed by three fields of widths 6, 8 and 5, respectively,
with left, left, and right justification, respectively, and
ends with the '<' character.
//-----------------------------------------------------------------------------
// Prompt to enter one sentence containing at least six tokens
//------------------------------------------------------------------------------
cout << " Enter one sentence containing at least six tokens. " <<;
//-------------------------------------------------------------------------------
// Read six tokens into string variables tok1, tok2,..., tok6.
//-------------------------------------------------------------------------------
string tok1,
tok2,
tok3,
tok4,
tok5,
tok6
i thought i had it figured out but its not compiling, any comments? :
#include <iostrean>
#include <iomanip>
using namespace std;
int main()
{
//-| ---------------------------------------
//-| Declare Variables
//-| --------------------------------------
string tok1, // First Token
tok2, // Second Token
tok3, // Third Token
tok4, // Fourth Token
tok5, // Fifth Token
tok6, // Sixth Token
//-| ------------------------------------------------------------------------
//-| 1. Prompt user to enter ONE sentence containing at least six (6) tokens.
//-| ------------------------------------------------------------------------
cout << "Enter one sentence containing at least six tokens." << endl;
//-| ------------------------------------------------------------------------
//-| 2. Read six tokens into string variables tok1, tok2,..., tok6.
//-| Declare Variables
//-| --------------------------------------
string tok1, // First Token
tok2, // Second Token
tok3, // Third Token
tok4, // Fourth Token
tok5, // Fifth Token
tok6, // Sixth Token
//-| ------------------------------------------------------------------------
//-| 1. Prompt user to enter ONE sentence containing at least six (6) tokens.
//-| ------------------------------------------------------------------------
cout << "Enter one sentence containing at least six tokens." << endl;
okay i got it to compile but this is the result: 1: The2: slow,3: fat,4: dog5: is6: pretty!
anyone know why?
heres my code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//-| ---------------------------------------
//-| Declare Variables
//-| --------------------------------------
string tok1, // First Token
tok2, // Second Token
tok3, // Third Token
tok4, // Fourth Token
tok5, // Fifth Token
tok6; // Sixth Token
//-| ------------------------------------------------------------------------
//-| 1. Prompt user to enter ONE sentence containing at least six (6) tokens.
//-| ------------------------------------------------------------------------
cout << "Enter one sentence containing at least six tokens." << endl;