Q:
Java program to store the time in a single integer variable
belongs to collection: Java Basic Programs
Java Basic Programs
- Java program to print \'Hello world\' (First program in Java)
- How to print different type of values in Java?
- How to read and print an integer value in Java?
- Java program to find sum and average of two integer numbers
- Java program to find Square, Cube and Square Root of an integer number
- Java program to check whether input number is EVEN or ODD
- Java program to swap two numbers with and without using third variable
- Java program to print uppercase and lowercase alphabets
- Java program to print Christmas tree
- Java program to print a rectangle using stars (java pattern program)
- Java program to print the diamond shape of stars
- Java program to print pattern of alphabets
- Java program to print Pascal\'s triangle
- Java program to generate permutation and combination of the numbers
- Java program to print all Armstrong numbers between given range
- Java program to find sum of all digits
- Java program to find mean of a given number
- Java program to build a calculator
- Java program to calculate compound interest
- Java program to validate input as integer value only
- Java program to print spiral pattern of the given input
- Java program to check whether a given character is alphabet or not
- Java program to print pattern of numbers in triangle and reverse trainable form
- Java program to print Floyd\'s triangle till given N rows
- Java program to convert string to Boolean
- Java program to print \'W\' pattern using stars
- Java program to count factors of a given number
- Program to verify answers of answer sheets of N students in Java
- Java program to compare two numbers with each other
- Java program to calculate area of Hexagon
- Java program to print prime numbers between given range
- Java program to print patterns (2 Examples based on numbers pattern)
- Java program to find perimeter of a rectangle
- Java program to generate random numbers between given ranges
- Java program to check whether a given number is ugly number or not
- Java program to check whether given number is Kaprekar number or not
- Java program to find cube 1 to N
- Java program to find the Length of Longest Sequence of 0\'s in binary form of a number
- Java program to find sum of factorials from 1 to N
- Java program to find the correct output of student quiz
- Java program to check Emrip number
- Java program to count number of notes (rupees) in given amount
- Java program to read marks between 1 to 100 (An Example of Exceptional Handling)
- Java program to divide two numbers and catch the exception, if divisor is 0
- Java program to handle multiple exceptions
- Java program to check Evil number
- Java program to check Harshad Number
- Java program to check Pronic Number
- Java program to check whether the number is IMEI Number or not
- Java program to convert given number of seconds to hours, minutes and second
- Java program to swap two numbers using function
- Java program to check number is positive, negative or zero
- Java program to find largest number among three numbers
- Java program to check whether year is Leap year or not
- Java program to demonstrate example of enum data type
- Java program to demonstrate example of this keyword
- Java example for while loop demonstration
- Java example for do while loop demonstration
- Java - Calculate Compound Interest using Java Program.
- Java - Greatest Common Divisor or Euclidean Algorithm Program or Highest Common Divisor
- Java - Greatest Common Factor or Euclidean Algorithm Program or Highest Common Factor
- Java - Calculate LCM (Least Common Multiple) using Java Program
- Java program to calculate HCF of two numbers
- Java program to multiply two numbers using plus (+) operator
- Java program to perform subtraction without using minus (-) operator
- Java program to print the value in decimal, octal, hexadecimal using printf() method
- Java program to calculate the employee and employer provident fund
- Java program to calculate the gratuity of an employee
- Java program to compare float and double values
- Java program to find the remainder without using modulus (%) operator
- Java program to check a given character is alphanumeric or not without using a built-in method
- Java program to check a given character is a digit or not without using the built-in library method
- Java program to check a given character is a whitespace character or not without using the built-in library method
- Java program to check a given character is an uppercase character or not without using the built-in library method
- Java program to check a given character is a lowercase character or not without using the built-in library method
- Java program to check a given character is a punctuation mark or not without using the built-in library method
- Java program to check a given character is a printable character or not without using the built-in library method
- Java program to convert a given number of days into years, weeks, days
- Java program to find the roots of a quadratic equation
- Java program to find the (GCD) Greatest Common Divisor
- Java program to find the (LCM) Lowest Common Multiple
- Java program to calculate the area of a triangle based on given three sides
- Java program to calculate the area of a triangle based on a given base and height
- Java program to calculate the area of Trapezium
- Java program to calculate the area of Rhombus
- Java program to calculate the area of Parallelogram
- Java program to calculate the area of Cube
- Java program to find the Surface Area and volume of the cylinder
- Java program to calculate the surface area, volume, and space diagonal of cuboids
- Java program to calculate the surface area and volume of Cone
- Java program to calculate the surface area and volume of Sphere
- Java program to calculate the mean, variance, and standard deviation of real numbers
- Java program to read coordinate points and determine its quadrant
- Java program to calculate the value of nCr
- Java program to calculate the value of nPr
- Java program to calculate the product of two binary numbers
- Java program to add two complex numbers
- Java program to extract the last two digits from a given year
- Java program to read the height of the person, and the print person is taller, dwarf, or average height person
- Java program to find the sum of two numbers using binary addition
- Java program to find subtraction of two numbers using binary subtraction
- Java program to extract bytes from an integer (Hex) value
- Java program to convert hexadecimal byte to decimal
- Java program to read a weekday number and print weekday name using switch statement
- Java program to read gender (M/F) and print the corresponding gender using a switch statement
- Java program to check whether a character is a VOWEL or CONSONANT using switch statement
- Java program to check whether the number is EVEN or ODD using switch statement
- Java program to find the number of days in a month using a switch statement
- Java program to validate date and print weekday of the given date
- Java program to clear console screen
- Java program to sleep program execution for specified milliseconds
- Java program to design a digital clock
- Java program to check a given IP address is valid or not
- Java program to check a given Email address is valid or not
- Java program to store the date in a single integer variable
- Java program to store the time in a single integer variable
- Java program to print string in hexadecimal format
- Java program to extract octets from IP address
- Java program to determine the class of a given IP address
- Java program to find the number of bits required to represent a number
- Java program to swap the first and second bits of an integer number
- Java program to check whether all bits of the number are UNSET (LOW)
- Java program to count total HIGH bits of the given number
- Java program to reverse bits of the given number
- Java program to swap two nibbles of a given byte
- Java program to demonstrate the example of left shift (<<) operator
- Java program to demonstrate the example of the right shift (>>) operator
- Java program to SET and CLEAR bits of the given number
- Java program to implement infinite loop using while loop
- Java program to implement infinite loop using do-while loop
- Java program to implement nested loop using for loop
- Java program to demonstrate the break statement with while and for loop
- Java program to demonstrate the break statement with a nested loop
- Java program to demonstrate the continue statement with while and for loops
- Java program to swap two numbers using bitwise operator
- Java program to check if all the bits of a given integer number are HIGH or not
- Java program to count the total HIGH bits in the given number
- Java program to check binary representation of the given number is palindrome or not
- Java program to check a given number is EVEN or ODD using bit masking
- Java program to check nth bit of 16-bit number is set or not
- Java program to check a number contains the alternative pattern of bits
- Java program to find the next number that is the power of 2
- Java program to find the position of MSB bit of an integer number
- Java program to find the highest bit set for a given integer number
- Java program to round off an integer number to the next lower multiple of 2
- Java program to count the number of leading zeros in a binary number
- Java program to swap two bits of a 32-bit integer number
- Java program to check a given number is the power of 2 using bitwise operator
- Java program to count the number of bits to be flipped to convert a number to another number
- Java program to print bits that need to be flipped to convert a number to another number
In this program, we will read hh, mm, ss variables from the user and store input date into a single integer variable using bitwise operators. Then we will also extract time and store it into hh, mm, ss variables.
Program/Source Code:
The source code to store time in a single integer variable is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we imported the "java.util.Scanner" package to read input from the user. And, created a public class Main. It contains a static method main().
The main() method is an entry point for the program. Here, we read time (hh mm ss) from the user. Then we stored the input time into a single variable using bitwise operators. After that, we also extracted the values for time's (hh mm ss) variables and printed the result.