For my class i have to write a program that has a method to combine integer time input values into a single double value, return that to a method that sums the values, then return that to a main. The method names i have written have to be exactly as they are shown, and i cannot for the life of me figure out how to call the "public static double RouteTotalOpera tionalTime(Scan ner input)" method into my main. If someone can explain to me how to call the method that would be great, thanks.
Code:
import java.util.*; public class Testpage { public static void main (String [] args) { /* want to call RouteTotalOperationalTime here and define it as variable name duration1 */ double duration1 = RouteTotalOperationalTime(); System.out.println("Duration is: " + duration1); } public static double RouteTotalOperationalTime(Scanner input) { System.out.println("How many runs?"); int runs = input.nextInt(); double duration = 0; for(int i=0; i<runs; i++) { System.out.println("How many hours?"); int hours = input.nextInt(); System.out.println("How many minutes?"); int minutes = input.nextInt(); double time = convertHoursMinutesToDouble(hours, minutes); duration += time+.5; } return duration; } public static double convertHoursMinutesToDouble(int hours, int minutes) { double Hours = hours/1.0; double Minutes = minutes/60.0; double sum = Hours+Minutes; return sum; } } /* The Error: Testpage.java:7: RouteTotalOperationalTime(java.util.Scanner) in Testpage cannot be applied to () double duration1 = RouteTotalOperationalTime(); ^ 1 error */
Comment