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]
2 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]2 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
The bullets button is available on the home tab of the ribbon in the ____ group.
Helga [31]
The bullets button is available on the home tab of the ribbon in the ____ group.
Paragraph
7 0
3 years ago
Why do designers use tonal shading?
Simora [160]

Designers use tonal shading because tonal shading gives a drawling dimension.


Hopefully this will help you out! :)

4 0
2 years ago
Read 2 more answers
3. Which of the following is most likely fake news?
ahrayia [7]

Answer:

C. An article that tries to sell you miracle weight loss pills

7 0
2 years ago
How many hours did it take supercomputer to calculate pi?
dybincka [34]
35 hours to be exact
3 0
3 years ago
You have been hired as the new Information Security consultant at XYZ Inc. Which of these employee behaviors would be a top secu
Temka [501]
D. Because don’t leave unattended laptops in public someone else will steal it
3 0
2 years ago
Other questions:
  • You can use the Ignore All button to ignore the current and all future occurrences of a flagged word. True or False
    5·1 answer
  • A user reports that a PC gets a BSOD on startup. A technician has researched the error message and found a driver to replace. Wh
    8·1 answer
  • The way a program is proceed is know as control flow and are :Sequence(one line after the other), Decision-making(either this or
    8·1 answer
  • Jake was working on an essay for his English class on a stormy Sunday afternoon. Before he could save his document, a big strike
    8·1 answer
  • The information stored in the _____ is used by the DBMS for a recovery requirement triggered by a ROLLBACK statement, a program'
    7·1 answer
  • What do you do when your computer shuts down
    15·2 answers
  • QUESTION 10
    10·2 answers
  • Accenture has partnered with a global construction company that specializes in building skyscrapers. The company wants better ma
    12·1 answer
  • Write a function called play_round that simulates two people drawing cards and comparing their values. High card wins. In the ca
    11·1 answer
  • A DTP firm has published and printed fliers for an upcoming fundraising event. In which section of the flyer would you find the
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!