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
sleet_krkn [62]
2 years ago
15

Write a program in Java programming language that given two clock times prints out the absolute number of minutes between them

Computers and Technology
1 answer:
Triss [41]2 years ago
7 0

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. ");

}

}

You might be interested in
Difference between Computer safety practices and precautions
nika2105 [10]

Answer: This is a partial list of basic safety precautions to use when working on a computer: Remove your watch and jewelry and secure loose clothing. Turn off the power and unplug equipment before performing service. Cover sharp edges inside the computer case with tape. Never open a power supply or a CRT monitor.

Make sure the space underneath your desk is free from clutter and your legs have room to move. Use your mouse as close to the keyboard as possible. Adopt good posture while at the computer. Know how to adjust your chair to the most comfortable position.

4 0
2 years ago
Write a statement that reads 5 successive integers into these variables that have already been declared: x1, x2, x3, x4, x5. The
prisoha [69]

Answer:

Following are the statement in C++ language :

#include <iomanip> // header file  

using namespace std; // namespace

int main() // main method  

{

   int x1,x2,x3,x4,x5; // variable declaration

cout<<" Enter the 5 sucessive integer:";

cin>>x1>>x2>>x3>>x4>> x5; // taking 5 input from user

cout<<right;

// prints each  of  its own line and form a right-justified  

cout<<setw(5)<< x1 << "\n" << setw(5) << x2 << "\n" <<setw(5) << x3 << "\n" << setw(5) << x4 << "\n" << setw(5) << x5 << "\n";

return(0);    

}

Output:

Enter the 5 sucessive integer: 45

23

445

6

8

 

  45

  23

 445

   6

   8

Explanation:

Description of program is given below  

  • Declared a 5 integer value x1,x2,x3,x4,x5 respectively.
  • Read the 5 integer value from user by using cin funtion.
  • Finally Print these 5 value in its own line and form a right-justified by using setw() function on it
5 0
3 years ago
The conflict between the user's goal for unfettered access to data and the security administrator's goal to protect that data is
rewona [7]

Answer: Access control

Explanation:Access control is the type of security facility that is provided to the systems in an organization. The functions carried out in maintaining the security of the system is done by authenticating , authorizing and identification of the users and related components . They are secured using the PINs , passwords, bio-metric scan etc.

The situation of the user wanting to have a unrestrained access towards data as well as maintaining the security is the done by access control.

8 0
2 years ago
Read 2 more answers
Sidney works in the accounting department. His boss just assigned him a task that involves creating budget formulas for the comp
MA_775_DIABLO [31]

In excel spreadsheets, Sidney need to consider specifying relationships between the information you have stored in your spreadsheets when creating formulas. The elements that will help you understand using spreadsheet are the constants, operators, references and functions. This will enable her to use the formulas, without hassle in spreadsheets.

3 0
2 years ago
Define and implement a method that takes a string array as a parameter and returns the length of the shortest and the longest st
Drupady [299]

Answer:

#HERE IS CODE IN PYTHON

#function to find length of shortest and longest string in the array

def fun(list2):

   #find length of shortest string

   mn=len(min(list2))

   #find length of longest string

   mx=len(max(list2))

   #return both the value

   return mn,mx

#array of strings

list2 = ['Ford', 'Volvo', 'BMW', 'MARUTI','TATA']

# call the function

mn,mx=fun(list2)

#print the result

print("shortest length is:",mn)

print("longest length is:",mx)

Explanation:

Create an array of strings.Call the function fun() with array as parameter. Here min() function will find the minimum string among all the strings of array and then len() function will find its length and assign to "mn". Similarly max() will find the largest string and then len() will find its length and assign to "mx". Function fun() will return "mn" & "mx".Then print the length of shortest and longest string.

Output:

shortest length is: 3

longest length is: 5

7 0
3 years ago
Other questions:
  • There are many careers within the IT industry. _____ are responsible for organizing a company's data, making sure all the data i
    9·1 answer
  • Which of the acronyms listed below refers to a series of basic hardware diagnostic tests performed by the startup BIOS after the
    13·1 answer
  • The network topology in which each device is connected directly to a central network switch
    9·1 answer
  • Which of these has an onboard key generator and key storage facility, as well as accelerated symmetric and asymmetric encryption
    10·1 answer
  • A security administrator wants to empty the DNS cache after a suspected attack that may have corrupted the DNS server. The serve
    12·1 answer
  • Image-editing software is used to_____
    7·1 answer
  • A network administrator determines who may access network resources by assigning users
    10·1 answer
  • Jiz<br>Active<br>2<br>3<br>- 2(7 - 15)<br>What is the value of<br>4​
    10·2 answers
  • NWhen you measure a person’s weight, you are measuring the
    15·2 answers
  • How do I add a Child to my Brainly account
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!