Hello elvis sarfo, the problem is in the way use to read the input "System.in.read()". Use another form of reading as "java.util.Scanner s = new Scanner(System.in);" Remember of the import the packager "import java.util.Scanner;"
In Java exists several way to reading of keyborad. Take a look here http://www.eol.ucar.edu/software/java/jdk1.3.1/docs/api/java/io/Reader.html I hope that helps On Aug 21, 1:14 pm, elvis sarfo <[email protected]> wrote: > Hi, i don't know what i did not do right here. > i created two classes; Employee and Employment and i and then i created an > array of 5 objects of the Employee class but the output that i am getting is > errorneous for me. Please help me . This is the code: > > public class Employee > { > private int EmpNum; > private double EmpSalary; > private int EmpAge; > public Employee(int num, double sal, int age) > { > this.EmpNum=num; > this.EmpSalary=sal; > this.EmpAge=age;} > > public int Age() > { > return EmpAge;} > > public double Salary() > { > return EmpSalary;} > > public int Num() > { > return EmpNum;} > } > > > > public class Employment > { > public static void main(String[] args) throws Exception > { > Employee[] Worker= new Employee[5]; > int Age; > int Number; > double Salary; > int x; > System.out.println("This is for five workers in my company"+"\n"); > for(x=0;x<5;x++) > { > System.out.println("\nWorker"+(x+1)+"\n"); > System.out.println("Enter your age:"); > Age=(int)System.in.read(); > System.in.read();System.in.read(); > System.out.println("Worker's Number:"); > Number=(int)System.in.read(); > System.in.read();System.in.read(); > System.out.println("Worker's Salary:"); > Salary=(double)System.in.read(); > System.in.read();System.in.read(); > Worker[x]=new Employee(Number,Salary,Age);} > > System.out.println("------------------------------------------------------- > -------------"); > for(x=0;x<5;x++) > { > System.out.println("\n worker :"+(x+1)+"\n" ); > System.out.println("Age:"+Worker[x].Age()+"\n Number:"+Worker[x].Num()+"\n > Salary:"+Worker[x].Salary()); > } > } > } > Thank you. --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
