Results 1 to 3 of 3
  1. #1
    prathamkool is offline Member
    Join Date
    Sep 2011
    Posts
    4
    Rep Power
    0

    Default class interface or enum expected Imports java.io.*; error

    hey I am new on java my prog is:



    Imports java.io.*;
    class IfElseNestedDemo
    {
    public static void main(String[] args)
    {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    System.out.println("enter the the marks");

    int testscore =Integer.parseInt(br.readLine());
    char grade;

    if (testscore >= 90)
    {
    grade = 'A';
    }
    else if (testscore >= 80)
    {
    grade = 'B';
    }
    else if (testscore >= 70)
    {
    grade = 'C';
    }
    else if (testscore >= 60)
    {
    grade = 'D';
    }
    else
    {
    grade = 'F';
    }
    System.out.println("Grade = " + grade);
    }
    }


    and I am getting an error..

    java:1:class interface or enum expected
    Imports java.io.*;
    ^
    1 error


    Plz help I am using jdk1.7.0

    thnx..
    Last edited by prathamkool; 09-29-2011 at 06:55 PM.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: class interface or enum expected Imports java.io.*; error

    The first line doesn't look right. Check it against examples of import statements in your textbook or notes.

  3. #3
    prathamkool is offline Member
    Join Date
    Sep 2011
    Posts
    4
    Rep Power
    0

    Default Re: class interface or enum expected Imports java.io.*; error

    hey I got ans thnx...

    import java.io.*;

    class IfElse
    {
    public static void main(String args[])throws IOException
    {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Enter marks = ");

    int testscore =Integer.parseInt(br.readLine());
    char grade;

    if (testscore >=90)
    {
    grade = 'A';
    }
    else if (testscore >=80)
    {
    grade ='B';
    }
    else if (testscore >=70)
    {
    grade = 'C';
    }
    else if (testscore >=60)
    {
    grade = 'D';
    }
    else
    {
    grade = 'F';
    }
    System.out.println("The Testscore is =" +grade);

    }
    }

Similar Threads

  1. Replies: 2
    Last Post: 10-02-2010, 03:13 AM
  2. class, interface or enum expected?
    By Addez in forum New To Java
    Replies: 2
    Last Post: 08-26-2009, 08:54 PM
  3. Replies: 1
    Last Post: 05-31-2009, 11:57 PM
  4. Replies: 1
    Last Post: 05-31-2009, 03:17 PM
  5. Replies: 16
    Last Post: 05-28-2009, 04:41 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •