Can someone make a suggestion please.
Let me know if the rest of the code is needed...
public void DisplayFile()
{
//line from input file
String InputLine = null;
String InputAge = null;
Integer IntAge = 0;
String InputName = null;
String InputAge2 = null;
Integer IntAge2 = 0;
BufferedReader UserInterface = null;
UserInterface = new BufferedReader( new InputStreamReader( System.in));
try
{
//repeat the loop as long as there is a line of text from the input file
while ((InputLine = InputFile.readLine() )!=null )
{
//while (Flag 'set to true')
//{
//if (Age is less 0 than and more than 120
//{
//flag = false
//}
//}
System.out.println( InputLine);
System.out.print( "Input Age:" );
InputAge = UserInterface.readLine();
IntAge = Integer.parseInt( InputAge );
//Check that the age entered is between 0 and 120
if (( IntAge <= 120 ) && ( IntAge > 0 ))
{
OutputFile.write( InputLine );
OutputFile.newLine();
OutputFile.write( IntAge.toString() );
OutputFile.newLine();
}
//Adding a new name using '0'
else if ( IntAge == 0 )
{
System.out.println( "Enter a new name" );
InputName = UserInterface.readLine();
//Giving the new name an age
do
{
System.out.println( "Enter an age" );
InputAge2 = UserInterface.readLine();
//check that the age entered is
} while (( IntAge2 <= 0 ) || ( IntAge2 > 120 ));
OutputFile.write( InputName );
OutputFile.newLine();
OutputFile.write( InputAge2.toString() );
OutputFile.newLine();
}
//Deleting a name using '-1'
else if ( IntAge < 0 )
{
System.out.println( InputLine + " deleted" );
}
//}
}
Doc1.doc (76K)
Number of downloads: 71
This post has been edited by jakkels: 30 May 2008 - 04:31 AM

New Topic/Question
Reply




MultiQuote




|