6 Replies - 258 Views - Last Post: 08 October 2012 - 09:42 AM Rate Topic: -----

#1 xnoviice  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 53
  • Joined: 05-October 11

question on a minute seconds

Posted 07 October 2012 - 07:49 PM

First I don't expect the question to be handed to me I just need a push.

Okay so right now what I am trying to do is enter minutes and then seconds and the seconds are to be 60 seconds or below (obviously) So the code I am trying right now is a bit like this
 

int min_total = 0;
int sec_total = 0;
const int minute = 60;
int seconds_to_min;
     
     cin >> min >> sec ;
     min_total = min_total + min;
     sec_total = sec_total + sec;
    sec_total = minute % sec_total;
    cout << min << sec;




is there any help that could be given? It would mean a lot if there was!

This post has been edited by xnoviice: 07 October 2012 - 07:54 PM


Is This A Good Question/Topic? 0
  • +

Replies To: question on a minute seconds

#2 jimblumberg  Icon User is online

  • member icon


Reputation: 4099
  • View blog
  • Posts: 12,690
  • Joined: 25-December 09

Re: question on a minute seconds

Posted 07 October 2012 - 08:06 PM

Help for what? You need to ask a question.

Jim
Was This Post Helpful? 0
  • +
  • -

#3 xnoviice  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 53
  • Joined: 05-October 11

Re: question on a minute seconds

Posted 07 October 2012 - 08:16 PM

Oh! sorry! um! okay well the question is when the seconds goes up to 60 how do I get it to be added into minuets and seconds go back down to 0??
Was This Post Helpful? 0
  • +
  • -

#4 jimblumberg  Icon User is online

  • member icon


Reputation: 4099
  • View blog
  • Posts: 12,690
  • Joined: 25-December 09

Re: question on a minute seconds

Posted 07 October 2012 - 09:08 PM

How would you do it using pencil and paper? In other words, how many seconds are in a minute? If you have 60 of something how to you get zero?

Jim
Was This Post Helpful? 1
  • +
  • -

#5 xnoviice  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 53
  • Joined: 05-October 11

Re: question on a minute seconds

Posted 08 October 2012 - 09:07 AM

Ok. Thanks! that's the little push I needed! I now have it working! I am going to put this here if anyone ever had the same question for reference! Thanks again!

const int minute = 60;

      cin >> min >> sec ;
     min_total = min_total + min;
     sec_total = sec_total + sec;
     min_total = min_total + sec_total / minute;     
     sec_total = sec_total % minute;




Was This Post Helpful? 0
  • +
  • -

#6 jimblumberg  Icon User is online

  • member icon


Reputation: 4099
  • View blog
  • Posts: 12,690
  • Joined: 25-December 09

Re: question on a minute seconds

Posted 08 October 2012 - 09:22 AM

What happens if minutes is larger than 60? I would also recommend the use of parentheses in your second min_total calculation. While not actually required they will make your intent much clearer. Also don't forget about the second "shortcut" form.

min_total = min_total + (sec_total / minute);  
// OR
min_total += sec_total / minute;



Jim
Was This Post Helpful? 1
  • +
  • -

#7 xnoviice  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 53
  • Joined: 05-October 11

Re: question on a minute seconds

Posted 08 October 2012 - 09:42 AM

Well for the program I am doing hours does not have to be involved for it is for the 80 minuets a CD can hold. also thank you for the reminder of cleaning up my code! I was just to excited finding it out to remember! :lol:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1