C212/A592 Introduction to Software Systems 2:30-3:45pm

http://www.cs.indiana.edu/classes/c212

Adrian German dgerman@indiana.edu Luddy Hall 2010

On the piece of paper write: 

  (a) name, username, major
  (b) reasons for taking this class
  (c) expectations, worries, concerns
  (d) what would you like to be able to do at the end of the course
      (that you can't do now) so you can feel accomplished 
  (e) let me know if you're not on the roster 

Textbook is available online (see readings off the site)

Java programs are made of classes. 
Classes are containers. They contain methods and variables. 
We call methods and variables: members. 
Classes have static or non-static members. 
Classes also have blueprints so they can be used to create objects. 

--

On the paper indicate whether you're coming from C200 or C211 and
then write a program that takes a number (like 2318746) and produces
the sum of the digits in that number. So in the case of 2318746 your
program should produce: 2 + 3 + 1 + 8 + 7 + 4 + 6 = 31

Answer is something like this:

[jwringer@silo c212-workspace]$ nano -w Exercise.java
[jwringer@silo c212-workspace]$ javac Exercise.java
Picked up _JAVA_OPTIONS: -Xms512m -Xmx512m
[jwringer@silo c212-workspace]$ java Exercise 123
Picked up _JAVA_OPTIONS: -Xms512m -Xmx512m
You typed: 123
6
[jwringer@silo c212-workspace]$ clear
[jwringer@silo c212-workspace]$ cat Exercise.java
public class Exercise {
  public static void main(String[] args) {
    String number = args[0];
    System.out.println( "You typed: " + number );
    int sum = 0;
    if (number.length() == 0) {
      System.out.println( sum );
    } else {
      for (int i = 0; i < number.length(); i++) {
        sum += (number.charAt(i) - '0');
      }
      System.out.println( sum );
    }
  }
}
[jwringer@silo c212-workspace]$ javac Exercise.java
Picked up _JAVA_OPTIONS: -Xms512m -Xmx512m
[jwringer@silo c212-workspace]$ java Exercise 123
Picked up _JAVA_OPTIONS: -Xms512m -Xmx512m
You typed: 123
6
[jwringer@silo c212-workspace]$