**Java version of this program is given bellow :**

/** * To change this template, choose Tools | Templates * and open the template in the editor. */ package statement; import java.util.Scanner; /** * * @author ACHCHUTHAN */ public class AddTime { int m1, m2, m3, m4, s1, s2, s3, s4, h1, h2, h3; public AddTime() { Scanner input = new Scanner(System.in); System.out.println("Enter the time from calculate \nHour :"); h1 = input.nextInt(); System.out.println("Minite :"); m1 = input.nextInt(); System.out.println("Second :"); s1 = input.nextInt(); System.out.println("Enter the next time for calculate\nHour :"); h2 = input.nextInt(); System.out.println("Minite :"); m2 = input.nextInt(); System.out.println("Second :"); s2 = input.nextInt(); } public void setTime() { if ((s1 + s2) < 60 && (m1 + m2) < 60) { h3 = h1 + h2; m3 = m1 + m2; s3 = s1 + s2; System.out.println("Addition of two times :"); System.out.print(h3 + "."); System.out.print(m3 + "'"); System.out.print(s3 + "''"); } if ((s1 + s2) < 60 && (m1 + m2) >= 60) { m3 = (m1 + m2) / 60; m4 = (m1 + m2) % 60; h3 = h1 + h2 + m3; s3 = s1 + s2; System.out.println("Addition of two times :"); System.out.print(h3 + "."); System.out.print(m4 + "'"); System.out.print(s3 + "''"); } if ((s1 + s2) >= 60 && (m1 + m2) < 60) { s3 = (s1 + s2) % 60; s4 = (s1 + s2) / 60; m3 = m1 + m2 + s4; h3 = h1 + h2; System.out.println("Addition of two times :"); System.out.print(h3 + "."); System.out.print(m3 + "'"); System.out.print(s3 + "''"); } if ((s1 + s2) >= 60 && (m1 + m2) >= 60) { s3 = (s1 + s2) % 60; s4 = (s1 + s2) / 60; m3 = (m1 + m2 + s4) % 60; m4 = (m1 + m2 + s4) / 60; h3 = h1 + h2 + m4; System.out.println("Addition of two times :"); System.out.print(h3 + "."); System.out.print(m3 + "'"); System.out.print(s3 + "''"); } } public static void main(String[] args) { AddTime A = new AddTime(); A.setTime(); } }

**Output of this program :**

run:

Enter the time from calculate

Hour :

5

Minite :

35

Second :

25

Enter the next time for calculate

Hour :

12

Minite :

25

Second :

59

Addition of two times :

18.1'24''BUILD SUCCESSFUL (total time: 14 seconds)

## Comments

## Post a Comment

Thank you for vising Java90.blogspot.com