import java.util.*;
import java.io.*;

public class Project6
{
	public static void main( String[] args )
	{
		
		int rows = 5;
		System.out.format("%d row triangle tree contains %d stars\n", rows, triStars(rows) );
		
		// S U M D I G I T S
		int number = 12345;
		System.out.format("sum of digits in %d = %d\n", number, sumDigits( number ) );
		
		// C O U N T 7 S
		number = 713274772;
		System.out.format("%d occurances of digit 7 in %d\n", count7s(number), number );
		
		// C O U N T 8 S -but- there is a twist! Any 8 with an 8 to its left counts as TWO 8s
		number = 82338828;
		System.out.format("%d occurances** of digit 8 in %d\n", count8s(number), number );

		// P O W E R N
		int base=2,exponent=8;
		System.out.format("%d to the power %d = %d\n", base, exponent, powerN(base,exponent) );	
	

		// I S S O R T E D 
		// perturb values as needed to test for your own benefit on an unsorted array (we will test on an unserted too)
		int[] array = { 7, 8, 12, 20, 21, 22, 37, 41, 55, 60, 65, 74, 83, 84, 87 };
		int startingAt=0;
		boolean isSorted = isSorted( array, startingAt, array.length );
		System.out.print( "array: ");
		for ( int i=0 ; i<array.length ; ++i ) System.out.print( array[i] + " " );
		if (isSorted)
			System.out.println(" is SORTED" );	
		else
			System.out.println(" is NOT SORTED" );	


		// P A L I N D R O M E
		String s = "stanleyyelnats"; // try with several differnt values that are or not palindromes	
		if ( isPalindrome( s, 0, s.length()-1 ) )
			System.out.format("%s IS a palindrome\n", s );	
		else
			System.out.format("\n%s NOT a palindrome\n", s ); 	
		
	} // END MAIN

	// count stars in a triangle using # of rows as input
	static int triStars(int rows)  
	{	if rows == 0 return 0
		return row + triStars(rows-1) ; 
	}
	// given a number return the sum of the digits
	static int sumDigits(int n) n = 314195
	{	
		return the last digit of n +  
			   sumDigits( n without the last digit )
	}
	// given a number compute the number of 7's in that number 
	static int count7s(int n) n = 713274772
	{	return 0;
		return the numbers found in the last digit of n
		       +  the number of 7 is the rest of the number 
	
	}
	// given a number count the number of 8 but if an 8 has another 8 to its immdiate left count it as 2 
	// the number 8802388 will return a count of 6  even tho only four literal 8s are there
	static int count8s(int n) 
	{	return 0;
		if the last 2 digits are 88 then
			return 2 + the number of 8s in the rest of the number 
		else if the last digit is an 8
			ret 1 + same thing 
		else 0 + the number of 8s in the rest of the number
	}
	//compute base to the power n
	static int powerN(int base, int n) 
	{	return 0;
	}
	// return true only if the array is sorted 
	static boolean isSorted(int array[], int i, int count ) 
	{	return false; // LOOK AT LAB #6
	}

	// return true if string is palindrome
	static boolean isPalindrome(String s, int lo, int hi ) 
	{	                   stanleyyelnats   0   length-1
	  the base case if test is based in the same whie ( test )
	  you did in the palindrome loop assignment 
	  if the base case is true then waht do you immediately return?
	  
	  test your lo and hi chars just like the loop version
	  if they are mis match ret false
	  
	}
} // END CLASS Project6
	
	
