r/learnjava • • 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?

0 Upvotes

8 comments sorted by

View all comments

6

u/NautiHooker Sep 16 '22

Please elaborate on what your issue is. What are you trying to achieve and what does not work?

-6

u/[deleted] Sep 16 '22

I am unable to make my method printIndex work.

5

u/NautiHooker Sep 16 '22

Elaborate on what your issue is. What are you trying to achieve in printIndex and what does not work?