Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Newbie
 
Join Date: Sep 2008
Posts: 2
#1: Sep 20 '08
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.

JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#2: Sep 20 '08

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


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
Nepomuk's Avatar
Moderator
 
Join Date: Aug 2007
Location: Germany
Posts: 2,466
#3: Sep 21 '08

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


Quote:

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)
Reply