/******************************************************************
 * Program: Hand Shakes
 *
 * Programmer: Tyler Johnson
 *
 * Due Date: N/A

 *
 * COMP 110-001        Instructor: Tyler Johnson
 *
 * Description: This program computes the number of hand shakes among
 *				n people if everyone shakes hands with everyone else
 *
 * Input: The number of people
 *
 * Output: The total number of handshakes
 *
 ******************************************************************/

import java.util.Scanner;

public class Handshakes  {

	public static void main(String[] args)  {
			
		int numPeople, numHandshakes;
		
		Scanner keyboard = new Scanner(System.in);
		
		System.out.println("Please enter the number of people");
		
		numPeople = keyboard.nextInt();
		
		if(numPeople < 1)  {
			System.out.println("Error - Number of people < 1.");
			System.exit(0);	//kill the program
		}
		
		numHandshakes = 0;
		
		for(int i = 1; i < numPeople; i++)  {
		
			for(int j = i + 1; j <= numPeople; j++)  {
			
				System.out.println("Person " + i + " shakes hands with Person " + j);
				numHandshakes++;
			
			}
		}
		
		System.out.println("\nThat results in " + numHandshakes + " handshakes");
	}
}