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-4

// input 3 number , one at a time , save them
// Then find the largest of the three and print it
// Important program to demonstrate use of 'if' ststements
// Noyice the double equal sign (  ==  ) on if statements


import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Application1 
{
     public Application1()
       {
        int num=0;
        int number;
        String cur_num;
        int n1=0;
        int n2=0;
        int n3=0;
        int big;  

                 do  {
                          cur_num = JOptionPane.showInputDialog("enter a number ");
                          number = Integer.parseInt(cur_num);    // convert to integer
                          num=num+1;
                          if (num==1) n1 = number;
                          if (num==2) n2 = number;
                          if (num==3) n3 = number;
                         }    while ( num < 3);
                   
                         if  ( n1 > n2)
                             {
                                if (n1 > n3)
                                     big = n1;
                                        else
                                           big = n3;
                             }
                            else
                             {
                               if ( n2 > n3)
                                  big=n2;
                                     else
                                        big=n3;
                              }

         

                        JOptionPane.showMessageDialog(null,"Largest is  "+big);

       }

     public static void main(String args[])
       {
         Application1 app = new Application1();
         System.exit(0);
       } 

}