title: C# : Seconds to Minutes to Hours conversion?
body: <p>Okay first off, I'm pretty sure I'm not expected to use TimeSpan for this assignment; rather a formula series which shows the seconds, minutes, and hours in a message box when the user enters the number of seconds in the text box.</p>
  
  <p>Here's where I'm stuck. We're supposed to check our answers with the example: 7565 seconds is 2 hours, 6 minutes, and 5 seconds. However, my code ends up calculating it as 2 hours, 6 minutes, and 6 seconds. It also keeps that answer when the initial number is 7560 seconds. I'm so confused!! It's a conditional scenario, in which the message box shows only the seconds if the user enters under 60 seconds, only minutes + seconds if the user enters between 60 and 3600 seconds, and hours + minutes + seconds if over 3600 seconds is entered.  Here is what I have so far, and I'd appreciate any insight as to why my calculation is off :)</p>
  
  <p>Thanks for the answers! But the 7565 isn't a constant; the user can enter any amount of seconds but my professor used 7565 as an example to check if we're on the right track.</p>
  
  <pre><code>private void calculateButton1_Click(object sender, EventArgs e)
      {
          int totalSeconds, hours, minutes, minutesRemainder, hoursRemainderMinutes, hoursRemainderSeconds;
          totalSeconds = int.Parse(secondsTextBox1.Text);
          minutes = totalSeconds / 60;
          minutesRemainder = totalSeconds % 60;
          hours = minutes / 60;
          hoursRemainderMinutes = minutes % 60;
          hoursRemainderSeconds = hoursRemainderMinutes % 60;
  
          if (totalSeconds &lt; 60)
          {
              MessageBox.Show(totalSeconds.ToString());
          }
  
          else if (totalSeconds &lt; 3600)
          {
  
              MessageBox.Show(minutes.ToString() + " minutes, " + minutesRemainder.ToString() + " seconds");
          }
  
          else if (totalSeconds&gt;3600)
          {
              MessageBox.Show(hours.ToString() + " hours, " + hoursRemainderMinutes.ToString() + " minutes, " + hoursRemainderSeconds.ToString() + " seconds");
          }
  
      }
  </code></pre>