need help with input and scanner keyboard..NEW TO JAVA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nitric
    New Member
    • Sep 2008
    • 2

    need help with input and scanner keyboard..NEW TO JAVA

    Hey guys,

    I am taking Programming I this semester and I am completely new to Java. for my FIRST assignment i need to write a Java program that will give me hours, minutes and seconds after I type in a number

    for example it should look like this:

    Enter numbers of seconds: (Where i type the number)

    Hours used: (how many hours in that number)
    Minutes used: (how many minutes in that number)
    Seconds used: (how many seconds in that number)

    so far my code looks like:

    [code=java]import java.util.Scann er;

    public class AssignmentNo1
    {
    public static void main(String[] args)
    {
    int hours, minutes, seconds;

    Scanner keyboard = new Scanner(System. in);
    System.out.prin tln("Enter number of seconds : ")
    seconds = keyboard.nextIn t();

    hours = seconds/3600;
    minutes = seconds/60;
    seconds = seconds%3600

    System.out.prin tln("Hours used:" + hours);
    System.out.prin tln("Minutes used:" + minutes);
    System.out.prin tln("Seconds used:" + seconds);
    }
    }[/code]

    When I compile it, it gives me an error in the "seconds = keyboard.nextIn t();" line saying : " wedge2: exit code for process is 1."

    thanks ALOT for any help.
    Last edited by Nepomuk; Sep 21 '08, 12:21 AM. Reason: Added [CODE] tags
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    I don't know what 'wedge2' is but I find it a very clumsy way of telling you that
    you've forgotten a semicolon at the end of the previous line. Drop that thing and
    simply use javac or a decent IDE.

    kind regards,

    Jos

    Comment

    • Nepomuk
      Recognized Expert Specialist
      • Aug 2007
      • 3111

      #3
      Originally posted by JosAH
      I don't know what 'wedge2' is but I find it a very clumsy way of telling you that
      you've forgotten a semicolon at the end of the previous line.
      By the
      way, that's not the only semicolon you've forgotten. Look through your code again.

      Oh, I've also replaced your [i] tags with [code] tags - they're thought for posting code and you should use them.

      Greetings,
      Nepomuk (Moderator)

      Comment

      Working...