• Post Reply Bookmark Topic Watch Topic
  • New Topic

need to get integer value instead of float value  RSS feed

 
fioana elegant
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

public class test {
public static void main(String[] args)
{
float minutes=92.2f;
double hour=Math.floor(minutes/60);
double min=Math.floor(minutes%60);
String time2=hour+":"+ min;
System.out.println("######################"+hour);
System.out.println("######################----"+min);
System.out.println("######################---------"+time2);

}


}
output is 1.0
32.2
but i need 1:32
can someone help???
 
Kevin Workman
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want an int, why are you storing them as doubles? Or you could just cast them as ints. Like so:
 
fioana elegant
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks alotttttttt kevin
 
Kevin Workman
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fioana elegant wrote:thanks alotttttttt kevin

No problem. Glad I could help.
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you mixing doubles and floats?

And please avoid misspellings like alottttt.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!