Professor Kit Romano's Web Site

 



Site Index

About Me

Welcome
Definition of Program
Variable Types
Understanding Memory
Declaring Variables
Simple Commands
Concatenation and Strings
Sleep-Threads-Try Catch
Campus Scenes
Pictures
Java simplified
Application Shell Styles
Reading Data From File
Overview of Applets
Excellent Graphics Applet
Online Reference
Nested if statements
Arrays
Sorting Arrays
Using Strings
Functions
Top 20 Replies 
First program 211
Important Class Example
JAVA in SDK Environment
Understanding OOP
OOP simple example
Recursion example
Example of Inheritance
     and use of JTextArea



*** Web Related **********
Build Student Web Page ?
What is FTP
Download WS ftp95
Download Java Plug In
Applets from jbuilder to sdk
Practice Problems

 

Programming Examples

 

 

                                                



First program 211

// a good starting shell for the first real program

import java.awt.*;
import java.net.*;
import java.io.*;
import java.awt.event.*;
import javax.swing.*;
public class Application1
{
public static void main(String[] args)
{

try
{
FileInputStream file_in = new FileInputStream("data1");
DataInputStream data_in = new DataInputStream(file_in);
char race, gender;
int age, weight;
int counter=0;
// declare the rest of your variables

       do
         {
            race = data_in.readChar();
            gender = data_in.readChar();
            age = data_in.readInt();
            weight = data_in.readInt();

       // make all your decisions and add to appropriate counters

            counter ++;

          }
              while ( counter <10);
// do any averaging and print final results

}        // end of try block
catch (IOException e )
{
JOptionPane.showMessageDialog(null,"file access problem");
}
System.exit(0);
}
}