/*
 * file :  hw3p3.c
 * ---------------------------
 * factor guessing game.
 */

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

void main()
{
  int myscore=0, shoescore=0;
  int number, factor;
  char another = 'V';

  while(another != 'N'){

    printf("Pick a number: ");
    number = GetInteger();

    printf("Now let your shoe guess a factor: ");
    factor = GetInteger();

    if(factor == 1 || factor == number){
      printf("Sorry, %d is a factor of %d, but it's too easy.\n", factor, number);
    }else{ /* not too easy! */
      if(number % factor == 0){
	printf("Yes, %d is indeed a factor of %d.\n", factor, number);
	shoescore ++;
      }else{
	printf("No, %d is not a factor of %d.\n", number, factor);
      }
    } /* not too easy! */
    printf("now let your shoe pick a number: ");
    number = GetInteger();

    printf("And you guess a factor: ");
    factor = GetInteger();
    if(factor == 1 || factor == number){
      printf("Sorry, %d is a factor of %d, but it's too easy.\n", factor, number);
    }else{ /* not too easy! */
      if(number % factor == 0){
	printf("Yes, %d is indeed a factor of %d.\n", factor, number);
	myscore ++;
      }else{
	printf("No, %d is not a factor of %d.\n", number, factor);
      }
    } /* not too easy! */

    printf("your score: %d, shoes score: %d\n", myscore, shoescore);

    another = 'V';
    while(another != 'Y' && another != 'N'){
      printf("Keep playing?[y/n] :");
      another = getchar();getchar();
      if (another >= 'a' && another <= 'z'){
        another = another - 'a' + 'A';
      }
    } /* while */
  }/* outer while */  

  if(myscore > shoescore)
    printf("you won!\n");

  if(myscore < shoescore)
    printf("you lost!\n");

  if(myscore == shoescore)
    printf("a draw!\n");
}






