Javaindepth24

Javaindepth24

Share

Our mission is to help people to find the best course online and learn with expert anytime, anywhere.

Learn Our best courses | JavaInDepth24 | Simplifying the skills 25/11/2022

Var- Arg Methods (Variable No Of Argument Methods) (1.5)

Until 1.4v we can't declared a method with variable no. Of arguments.

If there is a change in no of arguments compulsory we have to define a new method. By Using this approach it's increases length of the code and reduces readability. But from 1.5 version onwards we can declare a method with variable no. Of arguments such type of methods are called var-arg(Variable Argument) methods.

We can declare a var-arg(Variable Argument) method as follows.

Learn more

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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

Learn Our best courses | JavaInDepth24 | Simplifying the skills 04/11/2022

Grading Students Program

Problem

A University has the following grading policy:

1) Every student receives a grade in the inclusive range from 0 to 100.
2) Any grade less than 40 is a failing grade.

Sam is a professor at the university and likes to round each student's grade according to these rules:

1) If the difference between the grade and the next multiple of 5 is less than 3, round the grade up to the next multiple of 5.
2) If the value of grade is less than 38, no rounding occurs as the result will still be a failing grade.

Examples

1) grade = 84 round to 85(85 - 84 is less than 3)
2) grade = 29 do not round (result is less than 40)
3) grade = 57 do not round (60 - 57 is 3 or higher)

Given the initial value of each of Sam's students, write code to automate the rounding process.

Function Description

Complete the function gradingStudents.

gradingStudents has the following parameter(s):

1) int grades[n]: the grades before rounding

Returns

1) int[n]: the grades after rounding as appropriate

Input Format

The first line contains a single integer, n, the number of students.

Each line i of the n subsequent lines contains a single integer, grades[i].

Constraints

1

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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....

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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...

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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....

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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....

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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...

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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");
}
}

Task

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();
}
}

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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....

Learn Our best courses | JavaInDepth24 | Simplifying the skills 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

Want your school to be the top-listed School/college in Delhi?

Click here to claim your Sponsored Listing.

Location

Category

Telephone

Address


Nirman Vihar
Delhi
110092