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

 

 

                                                

 

Program 1-3

// input 3 number , one at a time and print total
// notice that data is input as a string and it must
// be converted to numeric before using it in arithmetic


import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Application1 
{
  public static void main(String args[])
       {
        //  declare all variables
        int total=0;
        int num=0;
        int number;
        String cur_num;

                 do  {
         // all data is input as String and the converted to int --next 2 commands
                           cur_num = JOptionPane.showInputDialog("enter a number ");
                           number = Integer.parseInt(cur_num);    // convert to integer
                           total=total + number;
                           num=num+1;
                         } while ( num < 3);
 
                        JOptionPane.showMessageDialog(null,"total is "+total);
         System.exit(0); 
       } 

}