/*----
  signature: main: void -> int
  purpose: to demo some interactive input/output

  compile using:
      g++ 112lect03-1-play.cpp -o 112lect03-1-play
  run using:
      ./112lect03-1-play

  by: Sharon Tuttle
  last modified: 2022-09-06 - although added another little
                              example after class
----*/

#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main()
{
    cout << boolalpha;

    //=====
    // cout default formatting demo
    
    double worm_wt = 3.0;
    string worm_name = "Harold";
    char worm_initial = 'H';

    cout << worm_wt << worm_name << worm_initial
         << endl;

    worm_wt = 10.0 / 3;

    cout << "worm_wt now: " << worm_wt << endl;

    //=====
    // cin playing!

    string a_whole_line;

    cout << "Enter a whole line: " << endl;
    getline(cin, a_whole_line);

    cout << "You entered: " << endl
         << '[' << a_whole_line << ']' << endl;
    
    int an_int;
    double a_double;
    char  a_char;
    string a_word;

    cout << "enter an int: ";
    cin >> an_int;

    cout << "enter a double: ";
    cin >> a_double;

    cout << "enter a char: ";
    cin >> a_char;

    cout << "enter a word: ";
    cin >> a_word;

    cout << "You entered: " << endl
         << an_int << endl
         << a_double << endl
         << a_char << endl
         << '[' << a_word << ']' << endl;

    // BECAUSE a getline expression after
    //    use of << will tend to read the
    //    newline that ended that last << use,
    //    IF you use getline on an input stream
    //    after <<, put in an extra getline to
    //    read in that rogue newline

    // TO READ IN that excess newline (sometimes
    //     called "FLUSHING" the newline):
    
    getline(cin, a_whole_line); 

    // and NOW we "mean" it:

    cout << "Enter a whole line: " << endl;
    getline(cin, a_whole_line);

    cout << "You entered: " << endl
         << '[' << a_whole_line << ']' << endl;
    
    return EXIT_SUCCESS;
}