Computer Science, asked by irenerebeccamaria72, 5 months ago

Define a java class ‘Time’ which has the following members.

Member variables :

hrs, min, sec, totSeconds. 

Member functions :

A parameterized constructor-Accepts hrs, min and sec from the main() method and initializes the member variables.

calc()-calculate the total seconds. (Hint: Convert hrs into mins and then both the mins into seconds and add up all the seconds).

display()-displays all the values.

The main() method should accept the values from the user and initialize  the values through a constructor.  It also calls or invokes the above functions.

Answers

Answered by manjulamanju54098
0

Answer:

Java Program to Calculate Difference Between Two Time Periods

public class Time {

int seconds;

int minutes;

int hours;

public Time(int hours, int minutes, int seconds) {

this. hours = hours;

this. minutes = minutes;

this. seconds = seconds;

Explanation:

Similar questions