Keep getting the non-static variable can not be referenced from a static context error ?
This is the main
package age_verification;
public class Main {
int month, day;
int year = 0;
public static void main(String[] args) {
calculate_age CalculateAge = new calculate_age();
Scanner user_input = new Scanner(System.in);
System.out.print("Please enter ");
month = user_input.nextInt();
System.out.print("Plese enter the day the person was born: ");
day = user_input.nextInt();
System.out.print("Please enter the Year the person was born: ");
year = user_input.nextInt();
CalculateAge.calculateAge(day);
}
}
And this is the Method
/*
package age_verification;
public class calculate_age {
Main calculation = new Main();
public void calculateAge(int age) {
age = 2011 - calculation.year;
System.out.printf("The person was born %d/%d/%d and is %d years old! ", calculation.month, calculation.day, calculation.year, age);
}
}

New Topic/Question
Reply




MultiQuote



|