Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2006

Tip: Looking for answers? Try searching our database.

converting number of minutes to number of days, hours, minuets

Thread view: 
whl - 12 Mar 2006 16:58 GMT
having some trouble writing this program and having to use
Interger.parseInt, and the JOptionPane options also.

Thanks for any help,
whl
Mitch - 12 Mar 2006 17:05 GMT
> having some trouble writing this program and having to use
> Interger.parseInt, and the JOptionPane options also.
>
> Thanks for any help,
> whl

The Calender class
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html should
help you deal with the time formatting issues.
whl - 12 Mar 2006 17:16 GMT
ok so as of now i have and input box that opens stating to enter number
of minuets to be converted.  That part is fine so now i am having to to
stat what is entered to be taken and done out to find nuber of
days,hrs,mins.  and using the % operator  and the /60 and then i am
getting lost and not sure how to go about this

thanks,
whl
Roedy Green - 12 Mar 2006 18:10 GMT
>ok so as of now i have and input box that opens stating to enter number
>of minuets to be converted.  That part is fine so now i am having to to
>stat what is entered to be taken and done out to find nuber of
>days,hrs,mins.  and using the % operator  and the /60 and then i am
>getting lost and not sure how to go about this

see http://mindprod.com/jgloss/mixedbase.html
http://mindprod.com/jgloss/time.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

whl - 12 Mar 2006 20:17 GMT
What if have so far

import javax.swing.JOptionPane;

public class part2 {

    /*
     NAME: Wai Houng Leung
     COS 160, Spring 2006, W 10:00 AM- 12:45 PM, Dr. Bantz
     Assignment: #2, I am taking COS 160 in Java*/

    /**
    * @param args
    */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        //---------------------------------------
        //                    Part 2
        //Converts a Number of Minutes to the
        //equivalent number of Day,Hours,and Minutes
        //
        //---------------------------------------

        String input;

        int minutes = 60 ;

        input = JOptionPane.showInputDialog("Enter Number of Minutes");

        int JOptionPane.showMessageDialog(null,input / minutes);

    }

    private static String minutes() {
        // TODO Auto-generated method stub
        return null;
    }

}
lost i guess
whl - 12 Mar 2006 20:17 GMT
what i have so far ,

import javax.swing.JOptionPane;

public class part2 {

    /*
     NAME: Wai Houng Leung
     COS 160, Spring 2006, W 10:00 AM- 12:45 PM, Dr. Bantz
     Assignment: #2, I am taking COS 160 in Java*/

    /**
    * @param args
    */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        //---------------------------------------
        //                    Part 2
        //Converts a Number of Minutes to the
        //equivalent number of Day,Hours,and Minutes
        //
        //---------------------------------------

        String input;

        int minutes = 60 ;

        input = JOptionPane.showInputDialog("Enter Number of Minutes");

        int JOptionPane.showMessageDialog(null,input / minutes);

    }

    private static String minutes() {
        // TODO Auto-generated method stub
        return null;
    }

}
guess i am lost
whl - 12 Mar 2006 20:18 GMT
what i have so far ,

import javax.swing.JOptionPane;

public class part2 {

    /*
     NAME: Wai Houng Leung
     COS 160, Spring 2006, W 10:00 AM- 12:45 PM, Dr. Bantz
     Assignment: #2, I am taking COS 160 in Java*/

    /**
    * @param args
    */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        //---------------------------------------
        //                    Part 2
        //Converts a Number of Minutes to the
        //equivalent number of Day,Hours,and Minutes
        //
        //---------------------------------------

        String input;

        int minutes = 60 ;

        input = JOptionPane.showInputDialog("Enter Number of Minutes");

        int JOptionPane.showMessageDialog(null,input / minutes);

    }

    private static String minutes() {
        // TODO Auto-generated method stub
        return null;
    }

}
guess i am lost
Oliver Wong - 16 Mar 2006 18:15 GMT
> what i have so far ,
>
[quoted text clipped - 37 lines]
> }
> guess i am lost

   See
http://www.cs.usm.maine.edu/~bantz/instruction/COS160/Spring05/COS160assignment2.html

<quote>
Hint: This program is short but a little tricky. You must use integer
division and remainder (modulus, %) even if you can think of a way to do
this without them. If the original number of minutes is stored in an int
variable named minutes, then the number of hours is minutes / 60. See page
78 of the text for a little more about integer division. The number of
minutes remaining after that number of hours has been accounted for is
minutes % 60.  See page 78 of the text for more on remainder.  See also
below.

Note on integer division and remainder:  If the values on both sides of a /
(division) operator are integers, the result will also be an integer.
Integers cannot represent a fractional value. That means that 5/2 cannot be
what we might expect (2.5), but is, in fact, the whole part of the resulting
value (2). The remainder is what remains after integer division. In grade
school you learned that 16/3 is 5 with aremainder of 1. The remainder
operator, %, evaluates 16 % 3 as 1.Both division and remainder work the same
if either or both of the operands is an integer variable instead of an
integer constant. Thus if we had a Java program with the following
statements in it:

int a = 16, b = 5, c, d;
c = a / b;
d = a % b;
// c would now have the value 3 and d would have the value 1
</quote>

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.