rockcairn logoRockCairn.com rockcairn logo
/********************************************************************
* Aaron Penner
* Homework1
* Due 1/25/2000 11:59PM
*
* Java command line application
* Input: three character sequences, the first two for number
* conversion, and the last ask plain text.
* Output: the greater of two numbers and the name field text in Caps.
*********************************************************************/

import java.io.*;
import java.text.*;

public class InputTest
{
public static void main(String[] args)
{
double num1;
double num2;
String yourname;

/* get the first number */
System.out.print ("Enter the first number: ");
try
{ InputStreamReader isr
= new InputStreamReader(System.in);
BufferedReader br
= new BufferedReader(isr);
String s = br.readLine();
DecimalFormat df = new DecimalFormat();
Number n = df.parse(s);
num1 = n.doubleValue();
}
catch(IOException e)
{ num1 = 0;
}
catch(ParseException e)
{ num1 = 0;
}

System.out.println ("");

/* get the second number */
System.out.print ("Enter the second number: ");
try
{ InputStreamReader isr
= new InputStreamReader(System.in);
BufferedReader br
= new BufferedReader(isr);
String s = br.readLine();
DecimalFormat df = new DecimalFormat();
Number n = df.parse(s);
num2 = n.doubleValue();
}
catch(IOException e)
{ num2 = 0;
}
catch(ParseException e)
{ num2 = 0;
}

System.out.println ("");

/* get the character sting as a name */
System.out.print ("Enter your name: ");
try
{ InputStreamReader isr
= new InputStreamReader(System.in);
BufferedReader br
= new BufferedReader(isr);
String s = br.readLine();
yourname = s.toUpperCase();
}
catch(IOException e)
{ yourname = "";
}

System.out.println ("");

/* print out hte results */
if (num1 > num2)
System.out.println("The Bigger of the numbers is: " + num1);
else
System.out.println("The Bigger of the numbers is: " + num2);

System.out.println ("");

System.out.println("Your name in caps is: " + yourname);
}
}