// demonstrates a function that is called 3
times. each time a number is
// input and converted to int and returned to the calling program
import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Application1
{
public Application1()
{
int num=0;
int number;
int n1=0;
int n2=0;
int n3=0;
int big;
do {
number = function1();
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);
}
//---------------------------------------------------------------------------------------------
// function1 inputs data, converts to int and returns value
public int function1()
{
String cur_num;
int n;
cur_num = JOptionPane.showInputDialog("enter a number ");
n = Integer.parseInt(cur_num); // convert to integer
return n;
}
//--------------------------------------------------------------------------------------------
public static void main(String args[])
{
Application1 app = new Application1();
System.exit(0);
}
}