/*
 * file :  hw3p1.c
 * ---------------------------
 * This program takes to numbers and compares their sum
 * with a guessed one.
 */

#include <stdio.h>
#include <math.h>
#include "simpio.h"

#define TOLERANCE 0.0001


void main()
{
  double num1, num2, sum, correctSum;
  char another = 'V';

  while(another != 'N'){
    printf("Give me a number: ");
    num1 = GetReal();
    printf("Give me another number: ");
    num2 = GetReal();

    printf("Guess the sum: ");
    sum = GetReal();
    
    correctSum = num1 + num2;
    if(fabs(sum - correctSum) < TOLERANCE ){
      printf("Right!\n");
    }else{
      printf("Wrong!\n");
    }
    another = 'V';
    while(another != 'Y' && another != 'N'){
      printf("Another?[y/n] :");
      another = getchar();getchar();
      if (another >= 'a' && another <= 'z'){
        another = another - 'a' + 'A';
      }
    }
  }
	   
  printf("okay, bye!\n");
}






