Help with Program!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mshroom12
    New Member
    • Feb 2008
    • 5

    Help with Program!

    Currently I was assigned an assignment that goes like this:

    Write an application that reads values representing a time duration in hours, minutes and seconds and then prints the equivalent total number of seconds.

    I use Eclipse to write my software and not that familiar with Java.

    Here's what I got so far.

    [CODE=java]public class TimeDuration {
    //
    // Prints a time duration from hours, minutes, and seconds and converts it into seconds
    //
    public static void main (String[] args)
    {
    double hours, minutes, sec, Xsec;

    Scanner scan = new Scanner (System.in);

    System.out.prin t("Enter the number of hours: ");
    hours = Double();

    System.out.prin t ("Enter the number of minutes: ");
    minutes = Double();

    System.out.prin t("Enter the number of seconds: ");
    sec = Double();

    Xsec = hours * minutes * sec;

    System.class.pr intln ("Time Duration of :" + Xsec);


    }
    }[/CODE]

    Can someone tell me what am I doing wrong and help correct those mistakes?

    Thanks a whole lot.
    Last edited by Ganon11; Feb 14 '08, 03:36 AM. Reason: Please use the [CODE] tags provided.
  • BigDaddyLH
    Recognized Expert Top Contributor
    • Dec 2007
    • 1216

    #2
    What syntax errors do you have?

    Comment

    • hirak1984
      Contributor
      • Jan 2007
      • 316

      #3
      Code:
      System.class.println ("Time Duration of :" + Xsec);
      this should be

      Code:
      System.class.println ("Time Duration of :" + Xsec);

      Comment

      • mshroom12
        New Member
        • Feb 2008
        • 5

        #4
        Originally posted by hirak1984
        Code:
        System.class.println ("Time Duration of :" + Xsec);
        this should be

        Code:
        System.class.println ("Time Duration of :" + Xsec);

        That looks like the exact same thing with no changes.

        Comment

        • mshroom12
          New Member
          • Feb 2008
          • 5

          #5
          Originally posted by BigDaddyLH
          What syntax errors do you have?
          Here's the list of errors that showed up after I ran the program,

          The method Double() is undefined for the type TimeDuration
          The method Double() is undefined for the type TimeDuration
          The method println(String) is undefined for the type Class

          at TimeDuration.ma in(TimeDuration .java:10)

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by hirak1984
            Code:
            System.class.println ("Time Duration of :" + Xsec);
            this should be

            Code:
            System.class.println ("Time Duration of :" + Xsec);
            You mean System.out.prin tln( ... ?

            Comment

            • JosAH
              Recognized Expert MVP
              • Mar 2007
              • 11453

              #7
              Originally posted by mshroom12
              Here's the list of errors that showed up after I ran the program,

              The method Double() is undefined for the type TimeDuration
              The method Double() is undefined for the type TimeDuration
              The method println(String) is undefined for the type Class

              at TimeDuration.ma in(TimeDuration .java:10)
              What is the method Double() supposed to do? There certainly isn't a method
              named Double() defined in that class (as the compiler tried to tell you).

              That 'class' thingy was just a silly litle mistake.

              kind regards,

              Jos

              Comment

              • hirak1984
                Contributor
                • Jan 2007
                • 316

                #8
                Originally posted by r035198x
                You mean System.out.prin tln( ... ?
                well precisely yes.
                i m sorry 4 the mistake

                Comment

                Working...