AbhaEmpire

AbhaEmpire Automate business solutions.

ArraysAn array is a group of homogenous variables that are referred to by a common name. We can create any type of array...
03/10/2022

Arrays

An array is a group of homogenous variables that are referred to by a common name. We can create any type of array and may have one or more dimensions. A specific element in an array is accessed by its index. Arrays provide a convenient means of grouping related information.

OR

An array is an indexed collection of a fixed number of like-typed data elements.

We can represent multiple values with the same name,this becomes the main advantage of arrays and it also improves the readability of the code .

But the main disadvantage of arrays is :

Arrays are fixed in size that is once we created there is no chance of increasing or decreasing the size of the array based on our need, that is ,to use arrays concept it is mandatory to know the size in advance which may not always be possible.

We can overcome this problem by using collections.

Array declarations :

Learn more....

Object-orientation is a perspective or way of thinking in terms of object on the basis of this thinking a programming model is devised by the name oops

Time Conversion Program In JavaProblemYou have given a time in 12-hour AM/PM format, convert it to military (24-hour) ti...
01/10/2022

Time Conversion Program In Java

Problem

You have given a time in 12-hour AM/PM format, convert it to military (24-hour) time.

Note :- 12:00:00AM will be 00:00:00 on a 24-hour clock and 12:00:00PM will be 12:00:00 on a 24-hour clock.

Example :

s='12:01:00PM'

Return '12:01:00'.

s='12:01:00AM'

Return '00:01:00'.

Function Description

Complete the timeConversion function. It should return a new string representing the input time in 24 hour format.

Function timeConversion has the following parameter(s) :

string s : a time in 12 hour format

Returns

string: The time in 24 hour format

Input Format

s a single string will represent a time in 12-hour clock format (i.e.: hh:mm:ssAM or hh:mm:ssPM).

Constraints

All input times are valid
Learn More...

Object-orientation is a perspective or way of thinking in terms of object on the basis of this thinking a programming model is devised by the name oops

Literals In JavaLiteralsAny constant value which can be assigned to the variable is called a literal.Example : int x=10;...
20/09/2022

Literals In Java

Literals
Any constant value which can be assigned to the variable is called a literal.

Example : int x=10;

Literals are divided as follows :

1) Integral Literals
2) Floating-point Literals
3) Boolean Literals
4) Char Literals
5) String Literals

1) Integral Literals :-

For integral data types (byte,short,int long) we can specify literal value in the following ways :-

i) Decimal Literals : It has a base of ten, and allowed digits are 0 to 9.

Example : Int x = 10;

ii) Octal Literals : It has base eight and allowed digits are 0 to 7.literal value should be prefixed with 0.

Example : int x = 010;

iii) Hexadecimal Literals :

> It has a base of 16.
> Allowed digits are 0 to 9, and characters from A to F.
> We can use both upper case and lowercase characters.
>This is one of very few areas where java is case sensitive but here java is not case sensitive. The Hexadecimal literal value should be prefixed with zero 0x or 0X

Learn More....

Object-orientation is a perspective or way of thinking in terms of object on the basis of this thinking a programming model is devised by the name oops

Java End-Of-File ProgramProblemThe problem here is to read n lines of input until you reach EOF, then number and print a...
16/09/2022

Java End-Of-File Program

Problem

The problem here is to read n lines of input until you reach EOF, then number and print all n lines of content.

Hint : You can use Java's Scanner.hasNext() method, It is helpful for this problem.

Input Format

you have to read some unknown n lines of input from stdin(System.in) until you reach EOF, each line of input contains a non-empty String.

Output Format

You have to print the line number for each line, followed by a single space, and then the line content received as input.

Sample Input

Hello world
I am a file
Read me until end-of-file.

Sample Output

1 Hello world
2 I am a file
3 Read me until end-of-file.

Solution

import java.util.Scanner;
Learn more....

Object-orientation is a perspective or way of thinking in terms of object on the basis of this thinking a programming model is devised by the name oops

Java DataTypes ProgramJava provides 8 primitive data types; char, boolean, byte, short, int, long, float, and double. Fo...
12/09/2022

Java DataTypes Program

Java provides 8 primitive data types; char, boolean, byte, short, int, long, float, and double. For this task, we'll work with the primitives used to hold integer values (byte, short, int, and long):

1) A byte is an 8-bit signed integer.
2) A short is a 16-bit signed integer.
3) An int is a 32-bit signed integer.
4) A long is a 64-bit signed integer.

You are given an input integer, you must determine which primitive data types are capable of properly storing that input.

Reference : https://javaindepth24.com/course/java/java-data-types

Input Format

The first line contains an integer, T, denoting the number of test cases.

Each test case, T, consists of a single line with an integer, n, which can be arbitrarily large or small.

Output Format

For each input variable n and appropriate primitive dataType, you must determine if the given primitives are capable of storing it. If yes, then print:

n can be fitted in:
* dataType

If you find there is more than one appropriate data type, print each one on its own line and order them by size (i.e.: byte < short < int < long).

If the number can't be stored in any one of the four primitive data types, print the line:

n can't be fitted anywhere.
Sample Input

5 // here 5 is t and denotes the number of test cases.
-150
150000
1500000000
213333333333333333333333333333333333
-100000000000000

Sample Output

-150 can be fitted in:
* short
* int
* long
150000 can be fitted in:
* int
* long
1500000000 can be fitted in:
* int
* long
213333333333333333333333333333333333 can't be fitted anywhere.
-100000000000000 can be fitted in:
* long

Explanation

We can store -150 in a short, an int, or a long data type.

213333333333333333333333333333333333 is a very large number and is outside of the allowable range of values for the primitive data types discussed in this problem.

Solution
import java.util.*;
class Solution{
public static void main(String []argh)
{
Scanner sc = new Scanner(System.in);
int t=sc.nextInt();

Learn more.....
https://javaindepth24.com/course/java-programs/java-datatypes

Object-orientation is a perspective or way of thinking in terms of object on the basis of this thinking a programming model is devised by the name oops

Java loops problemProblemWe use the integers a, b, and n to create the following series:(a + 20 x b), (a + 20 x b + 21 x...
09/09/2022

Java loops problem

Problem
We use the integers a, b, and n to create the following series:

(a + 20 x b), (a + 20 x b + 21 x b), (a + 20 x b + 21 x b + 22 x b),......

You are given q queries in the form of a, b, and n. For each query, print the series corresponding to the given a, b, and n values as a single line of n space-separated integers.

Input Format

The first line contains an integer, q, denoting the number of queries.
Each line i of the q subsequent lines contains three space-separated integers describing the respective ai, bi, and ni values for that query.

Constraints

1) 0 < q < 500
2) 0 < a,b < 50
3) 1 < n < 15

Output Format

For each query, print the corresponding series on a new line. Each series must be printed in order as a single line of n space-separated integers.

Learn more...

Object-orientation is a perspective or way of thinking in terms of object on the basis of this thinking a programming model is devised by the name oops

Here you have the opportunity to learn Java programming problems with solutions.Learn mostly solved java problems from h...
08/09/2022

Here you have the opportunity to learn Java programming problems with solutions.

Learn mostly solved java problems from here...
https://javaindepth24.com/course/java-programs/hello-program

Write a simple java Hello program ?
Output should be : Hello JavaInDepth24
class HelloJava{
public static void main(String[] args){
System.out.println("Hello JavaInDepth24");
}
}

Question

Given an integer, n , perform the following conditional actions:
If n is odd, print Weird
If n is even and in the inclusive range of 2 to 5, print Not Weird
If n is even and in the inclusive range of 6 to 20, print Weird
If n is even and greater than 20, print Not Weird
Input Format
A single line containing a positive integer, n.
Constraints
1 < n < 100
Output Format
Print Weird if the number is weird, otherwise, print Not Weird.
import java.util.*;
public class Solution {
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int N = scanner.nextInt();
scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
if(N%2==0){
if(N>=2&&N20)
System.out.println("Not Weird");
else
System.out.println("Weird");
}else
System.out.println("Weird");
scanner.close();
}
}

Object-orientation is a perspective or way of thinking in terms of object on the basis of this thinking a programming model is devised by the name oops

Java IdentifiersIDENTIFIER : Any name which is used in a Java program for identification is called identifier. It may be...
05/09/2022

Java Identifiers

IDENTIFIER :

Any name which is used in a Java program for identification is called identifier. It may be label name, variable name, method name and class name and package name and constant name and more.
Rule 1 : Allowed characters in java identifiers are :
1) a to z
2) A to Z
3) 0 to 9
4) _ (underscore)
5) $

Rule 2 : We will get a compile time error if we are using any other character.

Example :

1) total_amount -------valid
2) Amount # ------------------invalid

Learn More....

Object-orientation is a perspective or way of thinking in terms of object on the basis of this thinking a programming model is devised by the name oops

Java keywordsJava keywords that can be used only for their fixed and predefined purposes in the language. This means the...
02/09/2022

Java keywords

Java keywords that can be used only for their fixed and predefined purposes in the language. This means they cannot be used as identifiers, you cannot use them as names for classes, variables, interfaces, enums, or methods.

Learn more... https://javaindepth24.com/course/java/keywords

Address

Nirman Vihar
India Gate
110092

Alerts

Be the first to know and let us send you an email when AbhaEmpire posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Contact The Business

Send a message to AbhaEmpire:

Share