Results 1 to 4 of 4

Thread: Getting error

  1. #1
    manikos is offline Member
    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0

    Default Getting error

    while all other files run smooth, when i run this, i get an error. The error is:

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

    //-----------------------------------------------------------------------
    public class Metriseis {
    private int auxon_arithmos;
    private String wra_metrisis;
    private double timh_metrishs;

    Metriseis(){
    auxon_arithmos = 0;
    wra_metrisis = "";
    timh_metrishs = 0.0;
    }


    Metriseis(int x, String y, double z){
    auxon_arithmos = x;
    wra_metrisis = y;
    timh_metrishs = z;
    }



    public static String[] Xaraktirismos(Metriseis[] m, int ipsilo, int xamilo){
    String minima[] = new String[3];
    for(int i = 0 ; i < minima.lenght; i++){
    if(m.timh_metrishs[i] == ipsilo)
    minima[i] = "Max";
    else if(m.timh_metrishs[i] == xamilo)
    minima[i] = "Min";
    else
    minima[i] = "OK";

    }
    return minima;
    }

    }

    import java.io.*;
    public class Thema1 {
    public static void main(String args[])throws IOException{

    BufferedReader br = new BufferedReader(newInputStreamReader(System.in));

    Metriseis me[] = new Metriseis[3];
    int ipsilo = 30;
    int xamilo = 5;

    for(int i = 0; i<me.length; i++){
    System.out.print("Dose ton auxon arithmo metriseis: ");
    int auxon_arithmos = IntegerparseInt(br.readLine());
    System.out.print("Dose thn wra metriseis: ");
    String wra_metrisis = StringparseString(br.readLine());
    System.out.print("Dose tin timh metriseis: ");
    double timh_metrishs = DoubleparseDouble(br.readLine());
    me[i] = new Metriseis(auxon_arithmos, wra_metrisis. timh_metrishs);
    }

    String xar[] = new String[3];
    xar = Metriseis.Xaraktirismos(me, ipsilo, xamilo);

    for(int i = 0; i <xar.length; i++)
    System.out.println("O pinakas twn minimatwn einai : " + xar[i]);
    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Getting error

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Getting error

    1. import statements have to precede any other code.
    2. Each top-level public class must be in a separate, appropriately named file.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    manikos is offline Member
    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0

Similar Threads

  1. Replies: 3
    Last Post: 05-08-2012, 06:26 PM
  2. Replies: 1
    Last Post: 03-10-2010, 02:53 PM
  3. Replies: 1
    Last Post: 12-05-2009, 08:28 AM
  4. Replies: 1
    Last Post: 10-26-2009, 05:38 PM

Posting Permissions

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