I posted this on devshed.com's forums, but I have gotten no replies :sad: .
I am working on a program that reads data values from a file and uses them to compute the output. It is a tapemaker program that figures out how many minutes and seconds the songs take up on the tape. I have the data reading and printing done (it prints out in columns). The problem I am having is the process of converting 60 seconds to a minute when the seconds count goes over 60 (to add to the total minutes). The variables that get the three data items are snum (song number), min (length in minutes of the song), and sec (the remaining seconds). The image I include will make more sense of this. Also, I am having trouble getting the minutes left and second left (bottom of image). Some important variables are the length of the casette in minutes (size = 45) and the length of the casette in seconds (size_sec = size * 60). Thanks for all of your help!
The certain part that I am having a problem with is when the seconds reach 60, and then a minute must be added to the total and the seconds reset. However, the total seconds needs to remain the same.
Thanks for any help at all....

The image displays the proper output:

I think it might be best if you post the code you have so far. I think I might understand what your saying but I'm not sure.

public class Tapemaker
{
     public static void main (String args[])
                                   throws IOException
     {
          String dataNum;
          int size = 45;
          int size_sec = size * 60;
          int snum = 0;
          int min = 0;
          int sec = 0;
          int totmin = 0;
          int totsec = 0;
          int newtotsec = 0;
          int flag = 0;
          BufferedReader dataFile;
          
          dataFile = new BufferedReader( new FileReader("songdata.dat"));
          dataNum = dataFile.readLine();

          while (dataNum != null)
          {
               snum = Integer.valueOf( dataNum ).intValue();
               dataNum = dataFile.readLine();
               min = Integer.valueOf( dataNum ).intValue();
               dataNum = dataFile.readLine();
               sec = Integer.valueOf( dataNum ).intValue();

               if (snum == 0)
                  flag = 1;         //Flag is set to 1 so that no minutes and
                                      //seconds are added to total when snum = 1.)
                

               // This is the part I can't get! Here is where the total number of 
               // minutes and seconds are added, as explained in my post.
               


               dataNum = dataFile.readLine();
           }
           
           dataFile.close();
           
           //Total minutes and seconds are calculated here (I can't get this!)
           
          //Printing part is here (Not included...not important...)
     }
}

I hope this helps...

Try looking at this thread:
http://www.daniweb.com/techtalkforums/thread10700.html

It was talking about converting total seconds into H:M:S

Thanks, that helps with the last part of the output (minsand secs left). What would I do so that when 60 seconds are reached, a mnute is added to the total minutes, but the running total of seconds stays the same.
Thanks for your help.

Why not track total seconds (accumulate minutes * 60) and save this to the total seconds, along with the seconds column. then using the example I gave you above convert the total seconds back to HMS?

i need help using tapes. I have to read a tape from a text file then display the instructions the tape has and display it in an output file

your picture shows multiple values for the "total time" output. Shouldn't the total time only be displayed once?

while (dataNum != null)
		  {
			   snum += Integer.valueOf( dataNum ).intValue();
			   dataNum = dataFile.readLine();
			   min += Integer.valueOf( dataNum ).intValue();
			   dataNum = dataFile.readLine();
			   sec += Integer.valueOf( dataNum ).intValue();

			   dataNum = dataFile.readLine();
		   }
		   totmin = min + (sec / 60); //integer divided by integer returns an integer
		   totsec = sec % 60;  //modulus, get the remainder of the division
 
		   totSecLeft = size_sec - (min*60 + sec);
		   totMinLeft = totSecLeft / 60;
		   totSecLeft = totSecLeft % 60;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.