By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,389 Members | 2,070 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,389 IT Pros & Developers. It's quick & easy.

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

P: 2
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:

Expand|Select|Wrap|Line Numbers
  1. import java.util.Scanner;
  2.  
  3. public class AssignmentNo1
  4. {
  5. public static void main(String[] args)
  6. {
  7. int hours, minutes, seconds;
  8.  
  9. Scanner keyboard = new Scanner(System.in);
  10. System.out.println("Enter number of seconds : ")
  11. seconds = keyboard.nextInt();
  12.  
  13. hours = seconds/3600;
  14. minutes = seconds/60;
  15. seconds = seconds%3600
  16.  
  17. System.out.println("Hours used:" + hours);
  18. System.out.println("Minutes used:" + minutes);
  19. System.out.println("Seconds used:" + seconds);
  20. }
  21. }
When I compile it, it gives me an error in the "seconds = keyboard.nextInt();" line saying : " wedge2: exit code for process is 1."

thanks ALOT for any help.
Sep 20 '08 #1
Share this Question
Share on Google+
2 Replies


Expert 10K+
P: 11,448
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
Sep 20 '08 #2

Nepomuk
Expert 2.5K+
P: 3,112
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)
Sep 21 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.