1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alenkasestr [34]
3 years ago
13

Write a java program that prompts the user to input the elapsed time for an event in hours, minutes, and seconds. The program th

en outputs the elapsed time in seconds.
Computers and Technology
1 answer:
Arisa [49]3 years ago
6 0

Answer:

import java.util.*;

class seconds

{

public static void main (String[] args)

{

    Scanner takeinput=new Scanner(System.in);//creating a scanner object for taking input.

    int hour,min,sec; //declaring 3 variables for hour , minutes and seconds.

    System.out.println("enter hours");

    hour=takeinput.nextInt();//taking input of hours..

    System.out.println("enter minutes");

    min=takeinput.nextInt();//taking input of minutes..

    System.out.println("enter seconds");

    sec=takeinput.nextInt();//taking input of seconds..

    int tot_time_sec=(hour*60*60)+(min*60)+sec; //calculating time in seconds in variable tot_time_sec.

    System.out.println("Total time in seconds is "+tot_time_sec);//pritning total time in seconds..

}

}

For input:

7

20

45

Output is:-

Total time in seconds is 26445..

Explanation:

Above is the code for finding the time in seconds.I have taken three integer variables hour,min and sec for taking input of hours ,minutes and seconds. After taking input i have taken an integer variable tot_time_sec to store the calculated time in seconds and after that printing tot_time_sec.

You might be interested in
Which three features can be configured in the BIOS settings to secure a computer?
Vladimir79 [104]
Passwords, TPM, and Drive Encryption.

Hope this helps. :)
8 0
3 years ago
A typeface, plus any special attributes applied to the text is called ________.
grandymaker [24]

Answer:

I would like to say font but not sure

3 0
3 years ago
Read 2 more answers
Write a program in Java programming language that given two clock times prints out the absolute number of minutes between them
Triss [41]

Answer:

// Java Program to Find the difference

// between Two Time Periods

// Importing the Date Class from the util package

import java.util.*;

// Importing the SimpleDateFormat

// Class from the text package

import java.text.*;

public class GFG {

public static void main(String[] args) throws Exception

{

 // Dates to be parsed

 String time1 = "18:00:00";

 String time2 = "7:30:50";

 // Creating a SimpleDateFormat object

 // to parse time in the format HH:MM:SS

 SimpleDateFormat simpleDateFormat

  = new SimpleDateFormat("HH:mm:ss");

 // Parsing the Time Period

 Date date1 = simpleDateFormat.parse(time1);

 Date date2 = simpleDateFormat.parse(time2);

 // Calculating the difference in milliseconds

 long differenceInMilliSeconds

  = Math.abs(date2.getTime() - date1.getTime());

 // Calculating the difference in Hours

 long differenceInHours

  = (differenceInMilliSeconds / (60 * 60 * 1000))

  % 24;

 // Calculating the difference in Minutes

 long differenceInMinutes

  = (differenceInMilliSeconds / (60 * 1000)) % 60;

 // Calculating the difference in Seconds

 long differenceInSeconds

  = (differenceInMilliSeconds / 1000) % 60;

 // Printing the answer

 System.out.println(

  "Difference is " + differenceInHours + " hours "

  + differenceInMinutes + " minutes "

  + differenceInSeconds + " Seconds. ");

}

}

7 0
2 years ago
What is the capital for Russia
s344n2d4d5 [400]

Answer:

Moscow

Explanation:

Moscow is the capital of Russia and was made the capital in 1918.

4 0
3 years ago
Read 2 more answers
The Constitution party advances a conservative approach to issues and would most likely support policies that __________.
vodka [1.7K]
The correct answer for this question is this one
reflect our basic principles." The Constitution party advances a conservative approach to issues and would most likely support policies that <span>reflect our basic principles and as well as respect whatever what we believe in.</span>
3 0
3 years ago
Other questions:
  • Which view In a presentation program displays you’re slides in full screen modes ?
    8·2 answers
  • Which is the highest level of the hierarchy of needs model?
    5·2 answers
  • An indicator is a comprehensive analysis of critical information
    8·1 answer
  • How do airbags prevent injury?
    13·1 answer
  • Which sentence uses a pair of synonyms? Because there was so much shouting, many of the protestors began screaming in order to b
    6·2 answers
  • User can use ______ commands to search for and correct words in a document
    13·1 answer
  • How do you add Rulers to a document?: *
    6·1 answer
  • write a function that returns a list, where each member of list contains previous day’s value multiplied by 2.​
    15·1 answer
  • Icon view, list view, and details view are all common views provided by which kind of program?
    12·2 answers
  • How to transfer mysql database from one server to another
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!