I'm sorry AI choosse the wrong file
I'm sorry I choose the wrong file.
The error that I'm getting is this one:
Exception 'IOException' not caught or declared by 'void Lesson%.main(String[] args).
If I click the error and it take me to readLine() line, so I don't understand what happend.
Thanks
/**
* LESSON FIVE
*
* @author JAIME TORRES
* @version 1.0
*/
import java.io.* ;
class BadOpt extends Exception
{
public BadOpt( String option ) {}
public String BadOpt( String option )
{
if( option.equals("A") )
return(" Bad option: Caracas is the Capital of Venezuela") ;
if( option.equals("B") )
return(" Bad option: Santiago is the Capital of Chile" ) ;
else
return(" Bad option: Omaha is the bigest city in Nebraska" ) ;
}
}
class Lesson5
{
/*
* Constructor
*/
public Lesson5()
{} // empty
public static void main( String[] args)
{
String option = "D" ;
BufferedReader stdin = new BufferedReader( new InputStreamReader( System.in) ) ;
while( ! ( option.equals("E") ) )
{
try
{
System.out.println() ;
System.out.print("Please choose the correct answer:");
System.out.println() ;
System.out.println(" What is the capital of Colombia?" ) ;
System.out.println(" A. Caracas");
System.out.println(" B. Santiago");
System.out.println(" C. Omaha") ;
System.out.println(" D. Bogota");
System.out.println() ;
System.out.print("Your option is? " ) ;
option = stdin.readLine() ;
if( ! (option.equals("A")) )
throw (new BadOpt(option) );
}
catch ( BadOpt e )
{
System.out.println( e.BadOpt(option) ) ;
} // End catch block
} // End while loop
}
}

