Spring 2013 - Review

22 Apr 2013

Today moved to a lab and review day. The test will be Wednesday 24, 2013.

import java.util.ArrayList;</p>

public class example {

public static void main(String[] args)
{
int intYear = 2100;
boolean boolLeapYear = false;

//do
//scanner input
//while (<1582)

if(intYear % 4 == 0 && intYear % 100 != 0)
{
boolLeapYear = true;
}
else if(intYear % 400 == 0)
{
boolLeapYear = true;
}

//System.out.println(intYear + " is a leap year " + boolLeapYear);

//-----------------------------------------------
ArrayList aryCharacters = new ArrayList();
ArrayList aryLetters = new ArrayList();
String strParse = "Hello World";

for(char charCounter = 'A'; charCounter <= 'Z'; charCounter++)
{
aryCharacters.add(new Character(charCounter));
aryLetters.add(charCounter - 'A',0);
}
//System.err.println(aryLetters.size());

System.out.println(aryCharacters);
for(int intCharPosition = 0; intCharPosition < strParse.length(); intCharPosition++) { int intLocation = strParse.toUpperCase().charAt(intCharPosition); if(intLocation >= 'A' && intLocation <= 'Z')
{
//System.err.println(aryLetters.size() + ", " + intLocation + "=" + strParse.toUpperCase().charAt(intCharPosition));
//System.out.println(intLocation);
//Go to that location in the array store that stores number there.
Integer intNumber = aryLetters.get(intLocation - 'A');
//Add to the number there.
intNumber++;
//Store the number back in the right location.
aryLetters.set(intLocation - 'A',intNumber);
}
System.out.println(aryLetters);
}
//System.err.println(aryLetters.size());

//System.out.println(aryLetters);

//-----------------------------------------------
String strPassword = "access";

ArrayList aryValidPassword = new ArrayList();
aryValidPassword.add("HelloWorld");
aryValidPassword.add("access");
boolean boolValidPassword = false;

for(int intIndex = 0; intIndex < aryValidPassword.size(); intIndex++)
{
if(strPassword == aryValidPassword.get(intIndex))
{
boolValidPassword = true;
}
}

//System.out.println(strPassword + " is valid " + boolValidPassword);

}
}</code>

{"display_name"=>"chris", "login"=>"chris", "email"=>"crmacd@gmail.com", "url"=>"http://www.crmacd.com"}