// Trying out methods, part 2
// Author: Kiri Wagstaff
// Date: July 4, 2001

public class TensComplement
{
  // tensComplement: take in a number and output 10 minus that number
  // Input: a number from 0 to 10
  // Output: 10 minus the given number, or -1 if input is invalid
  public static int tensComplement(int n) 
  {
      int comp = 0;
      // Check input for invalid values
      if (n < 0 || n > 10)
      {
	  return -1;  // Signal an error
      }
		
      // Process: calculate the result
      comp = 10 - n;
		
      // Return the result
      return comp;
  }
	
  public static void main(String args[])
  {
      int number;
		
      System.out.println("Enter a number from 0 to 10:");
      number = SavitchIn.readLineInt();
		
      // Call the tensComplement method with number as the input
      // This method does something, and returns a value.
      int complement = tensComplement(number);

      // Print the result
      System.out.println("The 10's complement of " + number +
			 " is " + complement);		
  }
}
