public class Syntax
{
	public static void main(String [] args)
	{
		Syntax run = new Syntax();
		run.errorProne(10,200);
//		run.notRight();
//		run.tryThis(4,5);
	}
	
	public void endSameTest ( )
	{
		System.out.println("\n\n\n");
		System.out.println("edited -> " + endSame("edited"));
		System.out.println("ed -> " + endSame("ed"));
		System.out.println("eee -> " + endSame("eee"));
		System.out.println("edit -> " + endSame("edit"));
		System.out.println("e -> " + endSame("e"));
		System.out.println("java -> " + endSame("java"));
		System.out.println("null -> " + endSame(null));
		System.out.println(" -> " + endSame(""));
		System.out.println("\n\n\n");
	}
	
	public boolean endSame(String str)
	{
		if(str == null || str.length() == 0 || str.length() == 1)
		{
			return false;
		}
		if(str.substring(0,2).equals(str.substring(str.length()-2)))
		{
			return true;
		}
		return false;
	}
	
	public void minMod7Test ( )
	{
		System.out.println("12, 15 -> " + minMod7(12,15));
		System.out.println("14, 14 -> " + minMod7(14,14));
		System.out.println("24, 10 -> " + minMod7(24,10));
		System.out.println("8, 22 -> " + minMod7(8,22));
		System.out.println("26, 16 -> " + minMod7(26,16));
		System.out.println("61, 61 -> " + minMod7(61,61));
		System.out.println("\n\n\n");
	}
	
	public int minMod7(int a, int b)
	{
		if(a == b)
		{
			return 0;
		}
		if(a % 7 == b % 7)
		{
			if(a > b)
			{
				return a;
			}
			return b;
		}
		if(a > b)
		{
			return b;
		}
		return a;
	}
	
//  a.  variable value might not have been initialized
//  b.  array dimension missing
//  c.  not a statement
//  d.  incomparable types
//  e.  missing '{'
//  f.  cannot find symbol/undeclared variable
//  g.  else without if
//  h.  bad operand types for binary operator
//  j.  variable is already defined
//  k.  possible loss of precision
	
	public boolean errorProne(double x, double y)
	{
		char value = '1';
//		int [] myList = new int [];
//		value = x;
//		boolean b = (x < y) || value;
		
		if(x > value)
			System.out.println(x + " is greater!");
			
		else
		{
			System.out.println(value + " is greater!");
		}
		
//		do
//			value++;
//		} while(value < 100)
		
//		for(i = 0; i < 10; i+2)
//			if(value + i == 64)
//			{
//				return true;
//			}
		
//		double y = -1.5;
		boolean checker = false;
		
//		if(checker == value)
//			System.out.println("HELLO");
		
//		return value;
		return true;
	}
/*
	public void notRight()
	{
		String s = new String();
		boolean done = false;
		double value = 3.0;
		int count;
		
		do
		{
			int temp = (int)value + 1;
			System.out.println(done + temp);
		}while(!done);
		
		if(done)   {
			s += "FRED";
		}
		
		for(int count = 1; count = 10; count++)
		{
			s += count;
		}
	}
*/

/*
	public int tryThis(int a, b)
	{
		int r = (int)(Math.random * a);
		
		if(r = b)
			System.out.println("a = " a);
			
		double [] dd;
		
		for(int count = 0; count < a; count++)
			dd[count] = count * 2.0;
		}
		
		int x = 9.5 * a;
		
		int r = a * b
		
		return;
	}
*/
}

Back to APCS Main Page