Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Converting decimal number to m minutes, n.nn seconds format.

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Converting decimal number to m minutes, n.nn seconds format.

    I need to convert the solution for a user inputed number (for example 4.017) and have it print out the other side as minutes and seconds in the format m minutes, n.nn seconds. How would i do that?


  2. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Converting decimal number to m minutes, n.nn seconds format.

    How would i do that?
    By writing some code.

    Before you even start that, think about the task. How would *you* rather than a computer perform this arithmetic task?

    Once you have the answer to that (or, at least, an answer of which you are confident) you might want to review basic arithmetic operators (don't forget / and %). Then you can convert the method you would use into something the computer can use.

    If you have doubts about how you get input from the user, review these topics in your textbook or online tutorials.

    -----

    If you have difficulty seeing how *anyone* could possibly convert 4.017min into 4 minutes 1.02 seconds - or whatever it is - then post saying what ideas you have had, and any difficulties with them that you have.

    Once you have a plan but have some problem translating it into code, post what your plan is and what code you have come up with. If your code won't compile say what the compiler messages are. If it compiles but does something that you consider "wrong" at runtime, say what it does do and what you expect or intend it would do.

    -----

    Plan (B) might be to sit back and wait for someone to write the code for you. But I am sure you are not expecting anyone to do that.

Similar Threads

  1. Converting Hex to Decimal
    By r2ro_serolf in forum Java Theory & Questions
    Replies: 10
    Last Post: September 4th, 2011, 04:29 PM
  2. I want to extract minutes and seconds from duration
    By msa969 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 17th, 2011, 02:14 PM
  3. Java program to format a double value to 2 decimal places
    By JavaPF in forum Java Programming Tutorials
    Replies: 3
    Last Post: December 4th, 2010, 04:08 PM
  4. Java program to format a double value to 2 decimal places
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 3
    Last Post: December 4th, 2010, 04:08 PM
  5. [SOLVED] For loop-ing decimal format
    By Harj in forum Loops & Control Statements
    Replies: 10
    Last Post: October 1st, 2010, 05:47 PM