I have been asked to count the overal time of an album.
The user enters minutes and seconds in the formmat of mm.ss.
I have wrote the folowing code but I don't get the result I supposed to get.
I.E : 1st:3.55, 2nd 3.55 I got 7.1 instead of 7.50.
Any help would be appreciated.
public class TestClass {
static String delimeter = "\\.";
static int sec;
static int min;
public static void main (String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter track time in mm.ss");
double first = in.nextDouble();
System.out.println("Enter track time in mm.ss");
double second = in.nextDouble();
double overall = first +second;
String trackLength = String.valueOf(overall);
String[] songLengthSplit = trackLength.split(delimeter);
min = Integer.valueOf(songLengthSplit[0]);
sec = Integer.valueOf(songLengthSplit[1]);
int minToSeconds = min * 60;
int overallMinutes = (minToSeconds + sec) /60;
int reminder = (minToSeconds + sec) % 60;
System.out.print("Overall time is: " + overallMinutes + "minutes " + reminder + "seconds");