//Sum.java
// Counter-controlled repetition with the for structure

public class Sum {
public static void main( String args[] )
{
int sum = 0;
for ( int number = 2; number <= 100; number += 2 )
sum += number;
System.out.println("Sum Even Integers from 2 to 100\nThe sum is " + sum);
}
}

//Interest.java
// Calculating compound interest

public class Interest {
public static void main( String args[] )
{
double amount, principal = 1000.0, rate = .05;
System.out.println("Compound Interest");
System.out.println( "Year\tAmount on deposit\n" );
for ( int year = 1; year <= 10; year++ ) {
amount = principal * Math.pow( 1.0 + rate, year );
System.out.printf("%d\t%.2f\n",year, amount);
}
}
}

//LogicalOperators.java
// Demonstrating the logical operators

public class LogicalOperators {
public static void main( String args[] ) {
System.out.println("Truth Tables");
String output = "";
output += "Logical AND (&&)" +
"\nfalse && false: " + ( false && false ) +
"\nfalse && true: " + ( false && true ) +
"\ntrue && false: " + ( true && false ) +
"\ntrue && true: " + ( true && true );
output += "\n\nLogical OR (||)" +
"\nfalse || false: " + ( false || false ) +
"\nfalse || true: " + ( false || true ) +
"\ntrue || false: " + ( true || false ) +
"\ntrue || true: " + ( true || true );
output += "\n\nLogical AND (&&)" +
"\nfalse && false: " + ( false && false ) +
"\nfalse && true: " + ( false && true ) +
"\ntrue && false: " + ( true && false ) +
"\ntrue && true: " + ( true && true );
output += "\n\nLogical OR (||)" +
"\nfalse || false: " + ( false || false ) +
"\nfalse || true: " + ( false || true ) +
"\ntrue || false: " + ( true || false ) +
"\ntrue || true: " + ( true || true );
output += "\n\nLogical NOT (!)" +
"\n!false: " + ( !false ) +
"\n!true: " + ( !true );
System.out.println(output);
}
}