61.5k views
0 votes
write a function that will prompt the user for his/her age, // weight, and midicholrean count. Then calculate and return their // jedi level (returns a double). Remember to assign the retuned value // to the variable 'jedi_level'.

User JGFMK
by
5.9k points

1 Answer

5 votes

Answer:

Step-by-step explanation:

Assuming that the jedi_level is calculated by adding the age and weight of the individual and then dividing by the midicholrean count we can use the following Java function to grab all the required info from the user and calculate and return the jedi_level.

public static double JediLevel () {

Scanner in = new Scanner(System.in);

System.out.println("Enter age: ");

double age = in.nextDouble();

System.out.println("Enter weight: ");

double weight = in.nextDouble();

System.out.println("Enter midicholrean count: ");

double midi = in.nextDouble();

double jedi_level = (age + weight) / midi;

return jedi_level;

}

User Slowwie
by
7.4k points