r/learnjava • u/[deleted] • Sep 16 '22
Java Question
I am unable to make my printIndex method work.
import java.util.Scanner;
class Main {
public static void main(String[] args) {
String name;
int birthMonth;
int birthDay;
int timeAtm;
Scanner sc = new Scanner(System.in);
System.out.println("Please enter name:");
name = sc.nextLine();
System.out.println("Please enter birth month(enter in number form):");
birthMonth = sc.nextInt();
System.out.println("Please enter birth day:");
birthDay = sc.nextInt();
System.out.println("Please enter time(military)");
timeAtm = sc.nextInt();
}
public static int lengthofname (String name) {
int nameLength = name.length();
return nameLength;
}
public static int index (int name, int birthMonth, int birthDay, int timeAtm) {
int indexTotal = (timeAtm/name)+(birthMonth*birthDay);
return indexTotal;
}
public static void printIndex(int indexTotal){
if(indexTotal>500){
System.out.println("You will have a good day");
}
else {
System.out.println("You will not have a good day");
}
}
}
What can I do to fix it?
2
u/my5cent Sep 17 '22
You need to invoke the method in the main method.