// File: branching.cxx
// Written by Dmitry and Michael
// The purpose of this program is to give some first simple illustrations
// of if-statements and if-else statements.

//-----------------------------------------------------------------------------
#include <cstdlib>
#include <graphics.h>
#include <iostream>
using namespace std;
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// This function illustrates branching via graphics. It opens a window,
// and waits five seconds. At that point, it draws a shape that depends
// on where the mouse is as follows:
//   tall ellipse (left side of screen) or wide ellipse (right side of screen)
//   color1 (top of screen) or color2 (bottom of screen)
// The third parameter (window_size) is the size of the graphical window.
// After the shape is drawn, there is another five-second delay before the
// window closes and the function ends.
void draw_shape(int color1, int color2, int window_size);

// The lcm function calculates the least common multiple of two positive
// integers a and b.
int lcm (int a, int b);

// This function uses a graphical technique to estimate the value of pi.
// The parameter is the size of a graphical window that is opened as part
// of the process.
double pi(int window_size);
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
int main( )
{
    int value;
    cout << "Type your favourite number: ";
    cin >> value; //chislo - in russian!
    if (value == 42)      //statement, not a loop!!!
    {
	cout << "What a fine number!" << endl;
    }
    else if (value%2 == 1)
    {
	cout << "My how odd!" << endl;
    }
    else if (value%5 == 0)
    {
	cout << "5s are great!" << endl;
    }
    else
    {
	//catch part
	cout << "My favourite number is better than yours!" << endl;
    }
    if (value == 12 )
    {
	cout << "Ian's favourite number!" << endl;
    }
    else
    {
	cout << "It's not!" << endl;
    }

    //Nested if statement
    if (value%2 == 1)
    {
	cout << "That's still pretty odd" << endl;
	if (value%5 == 0)
	{
	    cout << "5 is alive!" << endl;
	}

    }

    
    cout << "Branching is fun!" << endl;
    return EXIT_SUCCESS;
}
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
void draw_shape(int color1, int color2, int window_size)
{
    
}
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
int lcm (int a, int b)
{
    int guess = a;

    while ((guess % a > 0) || (guess % b > 0))
    {
	++guess;
    }
    return guess;
}
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
double pi(int window_size)
{
    return 0;
}
//-----------------------------------------------------------------------------

