Computer Science, asked by rachayitaaa, 10 months ago

write a program in java to accept 2 time values in hours,minutes and seconds and display the sum of two value.
please see the above picture for reference and write the whole program.
please help me :)
thank you ❤​

Attachments:

Answers

Answered by shafiyil
1

Answer:

import java.util.*;

class time

{

Scanner sc=new Scanner (System.in);

int h1,h2,m1,m2,s1,s2,h,m,s;

void accept ()

{

System.out.println("Enter 1st time : ");

h1=sc.nextImt();

m2=sc.nextImt();

s1=sc.nextImt();

System.out.println("Enter 2nd time : ");

h2=sc.nextImt();

m2=sc.nextImt();

s3=sc.nextImt();

}

void calc()

{

s=s1+s2;

while (s>=60)

{

m=m+1;

s=s-60;

}

m=m+m1+m2;

while (m>=60)

{

h=h+1;

m=m-60;

}

h=h+h1+h2;

}

void display()

{

System.out.println("\n Total Time : Hours : "+h+" Minutes : "+m+" Seconds : "+s);

}

public static void main (String args[]);

{

time ob=new time();

ob.accept();

ob.calc();

ob.display();

}

}

Similar questions
Math, 5 months ago