// july14ex2.cpp : Defines the entry point for the console application.
// Create random price 1 - 100 until a trailer (0)is found.

#include "stdafx.h"
#include "stdlib.h"
#include "time.h"

int main(int argc, char* argv[])
{    int price, last, total=0, kount=0;
     int less=0, more=0, equal=0;


     srand(time(NULL));

     price = rand() % 101;

	 while (price != 0) {

	

       total+= price;
	   kount++;
	   printf("Item # %3d cost %3d ", kount, price);
	   if (kount != 1)  {      /* not the first time thru the loop ! */

           if (price < last) {
                printf(" which is less than the last price\n");
				less++;
			  } /* end if price < last */ 
		   else  if (price > last) {
                printf(" which is greater than the last price\n");
				more++;
			  } /* end if price > last */ 
		   else { printf(" which is equal to the last price\n");
		          equal++;
		   }
				
		 
	   }   /* end if kount */
	   else printf("\n");



       last = price;
	   price = rand() % 101; 
	 } /* while price */

    printf("Your total is $ %d \n", total);
	printf("You bought %d items\n", kount);

	printf("Num items less than prec = %d \n", less);
	printf("Num items greater than prec = %d \n", more);
	printf("Num items equal than prec = %d \n", equal);
	return 0;
}