473,383 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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

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
2 4753
JosAH
11,448 Expert 8TB
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
3,112 Expert 2GB
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

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

Similar topics

1
by: 848lu | last post by:
hey i really need help...i got this code....basically im suppose to make a calender that allows a user to type in month and year .... and the calander displays it on the scree using...
1
by: ray2007colon | last post by:
I need to now how to compare the elements of two arrays. Here is my program. Now I need to compare each element. So I can print the arrays and the elements that are not the same. import...
3
by: dalearyous | last post by:
ok basically i need to write a program that will replace normal words in a sentence with pirate words. the trick is it needs to be able to take two word phrases. i went about this two different ways:...
1
by: biznitchil | last post by:
it is a bit jacked up, but copy and paste it into an IDE(i use jGRASP) plz help me...it worked just fine before I added the menu..you can e-mail me if you have any <Removed> import java.util.*; ...
5
by: saytri | last post by:
Hi i have this project were i have to do a quiz. i wrote the questions in a textfile and i called them through java. I have also made a menu to choose which type of quiz. But before accessing the...
3
by: 100grand | last post by:
Modify the Inventory Program to use a GUI. The GUI should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price...
3
by: BlueroY | last post by:
hi, I'm working on an exercise, i did a lot of work already and i just can't figure where I'm going wrong, this is what I'm trying to achieve Sample IO...
6
by: cdm2883 | last post by:
here is my code, i am having trouble with getting my brakets in the right place so i can run my program. package mooredMod2; import java.util.Scanner; import java.util.Random; import...
4
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
I've got an application that takes input from a handheld scanner: Once the incoming text meets the RegEx format and is the correct length, the command is accepted. The scanner that plugs in on...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.