Link to home
Start Free TrialLog in
Avatar of Panos
PanosFlag for Germany

asked on

Java error

Hello experts
I have the following error:
C:\vaggelis\askisi1>javac newaskisi2.java
newaskisi2.java:61: error: possible loss of precision
 Akatharistos_Misthos = Mer_Erg * Hmer + 0.2 * Hmer * Yper;
                                                                 ^
  required: int
  found:    double
1 error

Attached my code
class Employee { 

private String Karta_Ypallhlou; 
private String Eponymia; 
private String AFM;
private int  Meres_Ergasias;
private double Hmeromisthio;
private float Yperories;
private float Syntelestis_Kratiseon;
private int Akatharistos_Misthos;


public Employee() { 
  Karta_Ypallhlou="";
  Eponymia =""; 
  AFM ="";
  Meres_Ergasias = 0;
  Hmeromisthio = 0.0;
  Yperories = 0.0f;
  Syntelestis_Kratiseon = 0.0f;
  Akatharistos_Misthos = 0;
  
} 
//pliris constructor 
public Employee(String Karta , String Epon, String AFM2, int Mer_Erg, double Hmer, float Yper , float Syntel, int Akatha) { 
Karta_Ypallhlou = Karta;
 Eponymia = Epon; 
 AFM = AFM2; 
 Meres_Ergasias = Mer_Erg;
 Hmeromisthio = Hmer;
 Yperories = Yper;
 Syntelestis_Kratiseon = Syntel;
 Akatharistos_Misthos = Akatha;
 

} 
public String getKarta_Ypallhlou () {
    return Karta_Ypallhlou;
}

public String getEponymia () { 
    return Eponymia;
 }
public String getAFM () { 
    return AFM; 
 } 

public int getMeres_Ergasias () { 
  return Meres_Ergasias; 
}
public double getHmeromisthio () { 
  return Hmeromisthio; 
}
public float getYperories() { 
  return Yperories; 
}
public float getSyntelestis_Kratiseon() { 
  return Syntelestis_Kratiseon; 
}
public int getAkatharistos_Misthos(int Mer_Erg, double Hmer, float Yper) {
 Akatharistos_Misthos = Mer_Erg * Hmer + 0.2 * Hmer * Yper;
 return Akatharistos_Misthos;
}


}
class TestEmployee { 

  public static void main(String args[]) { 
    Employee Yp = new Employee("Karta Ypallhlou" , "Nikos Nikas", "123456789", 25, 80.0 , 3.50f , 0.28f, 0);

    String ypal , name , AFM3;
    int Mer , Akatha ;
    double Hmero;
    float Ypero, Synt;
    
    
   
    
    ypal = Yp.getKarta_Ypallhlou();
    name = Yp.getEponymia(); 
    AFM3 = Yp.getAFM();
    Mer = Yp.getMeres_Ergasias();
    Hmero = Yp.getHmeromisthio();
    Ypero = Yp.getYperories();
    Synt = Yp.getSyntelestis_Kratiseon();
    Akatha =Yp.getAkatharistos_Misthos(25,80.0,3.5f) ;
    
    
    System.out.println("      Karta Ypallhlou   ");
    System.out.println(".........................");
    System.out.println("Eponymia      = " + name ); 
    System.out.println("Afm   = " + AFM3 ); 
    System.out.println("Meres_Ergasias    = " + Mer );
    System.out.println("Hmeromisthio     = " + Hmero ); 
    System.out.println("Yperories   = " + Ypero );
    System.out.println("Syntelestis Kratiseon = " + Synt);
    System.out.println(".........................");    
    System.out.println("Akatharistos Misthos = " + Akatha);
    
    
}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ken Butters
Ken Butters
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Panos

ASKER

Thank you for your help
Regards
Panos