I am using below to get the time remaining for playing games on iPhone.
int minutes_games_iPhone5 = 600;//minutes of 10 hour (static)
int games_iPhone5=(minutes_games_iPhone5*batteryinfo)/100; int hour_game_iPhone5 = games_iPhone5/60; int min_game_iPhone5 = games_iPhone5%60;log :hour:min = 8:30
Which works well, i guess.Now i need to figure out how can i show the same output in percentage,like 50%.
So 8:30 should also represent the value in percentage.How can i do that?
Thanks
8 hour 30 mintues equals to 8*60 + 30= 480+30=510min
Total time is 600min.
Therefore % is 510/600*100.
Convert this thing to code you will get the percent.
But use double/float otherwise you may end up with 0*100 in (510/600=0). Make it 510.0/600.