Can anyone help me with creating this code in Java? PLEASE! Thanks in advance!
Ask the user for the number of milliseconds, validate that it's not negative, and
display the result, then ask if the user wants to convert another number
(you may use a confirmation dialog, or you may allow input of 1 for yes
and 2 for no). Keep converting milliseconds until the user chooses no.
Example: (5500) should return 0:00:05 and convertMillis(100000) should return 0:01:40.
except your result MUST be formatted so that minutes and seconds are always two digits
6 4829
Do you want a complete code for this?
unfortunately we dont supply that.
If you want help,post the code you have tried.We will try to help.
Good Luck.
Can anyone help me with creating this code in Java? PLEASE! Thanks in advance!
Ask the user for the number of milliseconds, validate that it's not negative, and
display the result, then ask if the user wants to convert another number
(you may use a confirmation dialog, or you may allow input of 1 for yes
and 2 for no). Keep converting milliseconds until the user chooses no.
Example: (5500) should return 0:00:05 and convertMillis(100000) should return 0:01:40.
except your result MUST be formatted so that minutes and seconds are always two digits
Like hirak said we dont support full codes, you have to try and we will try to direct you in the right way.
Also this sounds like an assignment to me.
BSCode266
Using a good, clear thread title is important. The reasons for this are:
* We want this site to grow, many of our new members find the site using a search engine, by using a good thread title you will help us grow the site by helping us get better search engine rankings.
* Using a good title will benefit you too because other members of the forum will be less likely to skip over your thread and it allows the experts to quickly scan through the forum for questions they know the answer to.
* If the threads are well titled it allows other users to easily see if there have been any threads that could be relevant to their own current problem.
* It is in everybody's best interests to post properly titled threads as the more time the moderators have to spend on managing titles the less time they have available to give answers to the questions posed.
Sorry guys.
This is what I have so far. I can't figure out how the input can be converted.
Thanks for your help in advance! -
-
import javax.swing.JOptionPane;
-
public class extraCredit {
-
-
public static void main(String[] args) {
-
-
-
-
int choice;
-
do {
-
choice = Integer.parseInt(JOptionPane.showInputDialog(null, "Do you want to enter the milliseconds now?\n 1. Yes\n 2. No"));
-
-
switch (choice) {
-
case 1:
-
-
int milli;
-
do {
-
milli = Integer.parseInt (JOptionPane.showInputDialog("Enter the number of milliseconds (Must be positive"));
-
}
-
while (milli < 0);
-
-
break;
-
-
}
-
}
-
while (choice != 2);
-
-
-
-
}
-
}
Well you need not be sorry for whatever...
By the way are you facing problem in converting the string input into integer(the Integer.parseInt() stuff) or converting the input into millisecond?
please make this clear and preferrably post the errors you are getting.
Sorry guys.
This is what I have so far. I can't figure out how the input can be converted.
Thanks for your help in advance! -
-
import javax.swing.JOptionPane;
-
public class extraCredit {
-
-
public static void main(String[] args) {
-
-
-
-
int choice;
-
do {
-
choice = Integer.parseInt(JOptionPane.showInputDialog(null, "Do you want to enter the milliseconds now?\n 1. Yes\n 2. No"));
-
-
switch (choice) {
-
case 1:
-
-
int milli;
-
do {
-
milli = Integer.parseInt (JOptionPane.showInputDialog("Enter the number of milliseconds (Must be positive"));
-
}
-
while (milli < 0);
-
-
break;
-
-
}
-
}
-
while (choice != 2);
-
-
-
-
}
-
}
Hey
Thanks for your help. I figured it out. I needed help with the conversion from seconds to milliseconds so I just created a formula. 1 second to 1000 milli seconds. It was pretty simple after I figured it out. Thanks for your help though:)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: szymex |
last post by:
How can I get current time in milliseconds in ASP?
|
by: sgh |
last post by:
Why doesn't this date time pattern support milliseconds? That makes
it hard for me to map my date, time, and dateTime XML schema types to
System.DateTime values without losing millisecond...
|
by: Yeounkun, Oh |
last post by:
Hello.
Sleep (x) function make a process sleep during x seconds.
but, how to sleep during milliseconds...
Pls. help me.
Thank you. Regards.
|
by: Stu |
last post by:
Hi,
How can you get the time accurate to the millisecond?
Thanks in advance,
Stu
|
by: Jason S |
last post by:
is there any way to use templates to bind integer/floating point
constants to a template for compile-time use?
e.g.
template <double conversion>
class meters
{
const factor = conversion;
|
by: Manikandan |
last post by:
Hi,
I'm inserting a datetime values into sql server 2000 from c#
SQL server table details
Table name:date_test
columnname datatype
No int
date_t DateTime
...
|
by: Grey Alien |
last post by:
I need to convert timestamps that are given as the number of seconds
that have elapsed since midnight UTC of January 1, 1970, (not counting
leap seconds).
It seems all of the std C functions...
|
by: Hunter |
last post by:
Hi all,
I know it may sound like dump newbie question (which is very much
true, as I am a newbie, not even a real programmer), but I need to
implement a calendar time clock with a millisecond...
|
by: maul581 |
last post by:
I know the delay( ) function of Turbo C and used it in my project. By this function we can give intermediate delay in execution from 1 millisecond to 9999 millisecond.
My main question is "Is it...
|
by: maolimix |
last post by:
Hi to all,
I have a trouble with datetime...now I explain..
I must to store to a C# variable the values from a "Datetime column" of Sql Server 2005.
I tried 3 methods ...in the first two I never...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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$) {
}
...
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |