Hi :) any help with this would be appreciated as I really should know this by now. Kinda sad I'm just not gripping the simple stuff.
I was wondering how I'd go about this. The user inputs the minutes spent in each activity. So-
The program prompts the user to enter how many minutes and they do.
for example:
badminton = 30 mins
running = 20 mins
walking = 45 mins
weight lifting = 20 mins
How would my code look to add up all those minutes to make it into h:mm format?
My professor said I need to use the / and the % functions. He also said it divides by 60. example, 256/60 = 4 hrs with 16 mins as the remainder
I get the basic premise but not how to input this into code.
You have the activities, now all you need is another variable you can call total for example where you sum the minutes in all the activities. It should look like this:
badminton = 30 mins
running = 20 mins
walking = 45 mins
weight lifting = 20 mins
total = badminton + running +walking + weight lifting min
You know from math that dividing the minutes by 60 should give how many hours. So it should look like this: int hours = total / 60; and that minutes is the module so it should be
int minutes = total % 60;
Now you only need to output it.
If you need more tips, dont worry about asking again!