請JAVA高手幫幫忙

想請JAVA高手幫我寫一個簡單的程式 拜託了 或是給我一些提示之類的><

The first vessel runs between Odgen Point in Victoria and Parsons Point in Sooke and costs $ 485.00 per hour to operate. The second vessle runs between Odgen Point in Victoria and Roberts Point in Sydney and costs $595.00 per hour to operate. Your task will be to write a program that calculates the total daily operational hours and the gross daily operational cost for the cooperative. The input to your program will be numbers of runs and durations extracted from the daily ferry schedule, an example of which is here. each run requires an additional half hour of operational time for loading and unloading.

Update:

time and trip durations should be input as 2 integer values, one representing the hours (on a 24 hour clock) and one representing the minutes. You can assume that all times are on the same day. Your program should make use of static methods whereever possible

Update 2:

This method will expect that the input parameter hours contains an integer value that represents a number of hours and the input parameter minutes contains an integer value that represents a number of minutes.

Update 3:

我目前只想到用這個.

System.out.print("Input hour (24 hour clock)==> ");

int hour = stdin.nextInt();

System.out.print("Input minutes ==>");

int minute = stdin.nextInt();

double time = convertHoursMintuesToDouble(int hours, int minutes);

Update 4:

One method that must be used has the following method signature:

public static double RouteTotalOperationalTime(Scanner input)

實在很緊急...拜託會寫的大大抽空幫我一下了 希望我的題目寫得夠清楚. 先謝謝了

Update 5:

.......太*了 = =

請問你是UVIC學生?!?!?!

我也在UVIC拿CSC110

有沒有這麼巧 ..

Update 6:

我compile之後 有3errors出現

java4:cannot resolve symbol

symbol: class Scanner

location: class Y03844

public static double routeTotalOperationalTime(Scanner input) {

^

Update 7:

java28:cannot resolve symbol

symbol: class Scanner

location:class Y03844

Scanner input = new Scanner(System.in);

^

java28: cannot resolve symbol

symbol:class Scanner

location:class Y03844

Scanner input=new Scanner(System.in);

^

謝謝你

2 Answers

Rating
  • 1 decade ago
    Favorite Answer

    請參考我的做法

    import java.util.*;public class Y03844 { public static double routeTotalOperationalTime(Scanner input) { System.out.print("Input the number of runs from this route ==> "); int runs = input.nextInt(); double totalTime = 0.0D; for (int i = 1; i <= runs; i++) { System.out.println("For run #" + i); System.out.print("Input hour (24 hour clock)==> "); int hour = input.nextInt(); System.out.print("Input minutes ==>"); int minute = input.nextInt(); double d = convertHoursMintuesToDouble(hour, minute); System.out.println("" + d); totalTime += d + 0.5D; } return totalTime; } public static double convertHoursMintuesToDouble(int hours, int minutes) { return hours + minutes/60.0D; } public static void main(String[] args) { double dailyOperationalHours = 0.0D; double dailyOperationalCost = 0.0D; Scanner input = new Scanner(System.in); System.out.println("=== Odgen Point Victoria --> Parsons Point Sooke ==="); double d = routeTotalOperationalTime(input); dailyOperationalHours += d; dailyOperationalCost += 485 * d; System.out.println("=== Parsons Point Sooke --> Odgen Point Victoria ==="); d = routeTotalOperationalTime(input); dailyOperationalHours += d; dailyOperationalCost += 485 * d; System.out.println("=== Odgen Point Victoria --> Roberts Point Sydney ==="); d = routeTotalOperationalTime(input); dailyOperationalHours += d; dailyOperationalCost += 595 * d; System.out.println("=== Roberts Point Sydney --> Odgen Point Victoria ==="); d = routeTotalOperationalTime(input); dailyOperationalHours += d; dailyOperationalCost += 595 * d; System.out.println("Daily Operational Hours = " + dailyOperationalHours + " hours"); System.out.println("Daily Operational Cost = $" + dailyOperationalCost); }}

    2008-10-07 18:38:41 補充:

    沒錯,感謝智民大大補充

  • 志明
    Lv 5
    1 decade ago

    這一行要貼

    import java.util.*;

Still have questions? Get your answers by asking now.