So I would like to start out by telling you that I am learning Java on my own and you guys are the nearest thing I have to teachers. So thank you so much for putting up with my simple and obvious question. I am just trying to learn. Once again I am getting an error that for the life of me I cannot figure out.
Here is the error:
Exception in thread "main" java.lang.NullPointerException
at Advisor_score.All_user.Score1(All_user.java:13)
at Advisor_score.All_user.main(All_user.java:28)
Here is my code for the ratings class:
package Advisor_score;
public class Rating {
double [] Ratings;
double sum=0;
double raw_advisor;
double advisor_score;
public Rating (double [] x){
Ratings = x;
}
public double Score(){
for(int i=2;i<Ratings.length;i++){
sum+=Ratings[i];
}
raw_advisor=((sum-(3*(Ratings.length-2)))/4);
advisor_score= 2.5+(2.5*(1-Math.pow(Math.E, -.5*raw_advisor)));
return advisor_score;
}
Here is my code for the other class:
package Advisor_score;
public class All_user{
double [] ADVISOR_SCORE;
Rating [] All_users;
double score;
public All_user(Rating...args){
All_users=args;
}
public double [] Score1(){
for (int j = 0;j<All_users.length;j++){
score=All_users[j].Score();
ADVISOR_SCORE[j]=score;
}
return ADVISOR_SCORE;
}
public void print(){
for(int i = 0;i<ADVISOR_SCORE.length;i++){
System.out.println(ADVISOR_SCORE[i]);
}
}
public static void main(String[] args){
double p1_1[] = {101,1,5,5,5};
double p2_1[] = {101,1,1,2,3};
Rating d = new Rating(p1_1);
Rating e = new Rating(p2_1);
All_user all=new All_user(d, e);
all.Score1();
all.print();
}
}
Again, I cannot thank you guys enough at StackOverflow. Your help has been invaluable!!