Re: converting number of minutes to number of days, hours, minuets
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: Thu, 16 Mar 2006 17:15:37 GMT
"whl" <waihoung.leung@xxxxxxxxx> wrote in message news:1142191090.664857.174570@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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
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
.
- References:
- converting number of minutes to number of days, hours, minuets
- From: whl
- Re: converting number of minutes to number of days, hours, minuets
- From: Mitch
- Re: converting number of minutes to number of days, hours, minuets
- From: whl
- Re: converting number of minutes to number of days, hours, minuets
- From: Roedy Green
- Re: converting number of minutes to number of days, hours, minuets
- From: whl
- converting number of minutes to number of days, hours, minuets
- Prev by Date: Re: Need help to make a button smaller
- Next by Date: Using Classes Not In Classpath
- Previous by thread: Re: converting number of minutes to number of days, hours, minuets
- Next by thread: Java applet: how to run outside browser ?
- Index(es):
Loading