View Single Post
Join Date: Apr 2007
Posts: 40
Reputation: rapperhuj is an unknown quantity at this point 
Solved Threads: 0
rapperhuj rapperhuj is offline Offline
Light Poster

Re: Else If statement

 
0
  #6
Sep 6th, 2007
arg.. a new error occured. >.< this is my only notes/guide for the if else statement. =(
  1. import java.io.*;
  2. public class input{
  3. public static InputStreamReader Reader=new
  4. InputStreamReader(System.in);
  5. public static BufferedReader input=new
  6. BufferedReader(Reader);
  7. public static void main(String args[]){
  8. String name;
  9. int age;
  10. {
  11. System.out.println("Enter name:");
  12. name=input.readLine();
  13. System.out.println("Enter age:");
  14. age=Integer.parseInt(input.readLine());
  15. if (age<=17){
  16. System.out.println("Too young!");
  17. } else if(age>=18){
  18. System.out.println("You're ready to vote!");
  19. }
  20. }
  21. }
  22. }
The error says:
- unreported exception java.io.IOException; must be caught or
declared to be thrown line 12
  1. name=input.readLine();
- unreported exception java.io.IOException; must be caught or
declared to be thrown line 14
  1. age=Integer.parseInt(input.readLine());
It seems like my teacher forgot something or I copied the code wrong. =(
Last edited by rapperhuj; Sep 6th, 2007 at 10:48 pm.
Reply With Quote