Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
Core Java and Java 8
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lokesh Singh
Core Java and Java 8
Commits
5eefb58a
Unverified
Commit
5eefb58a
authored
May 17, 2022
by
Lokesh Singh
Committed by
GitHub
May 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add files via upload
parent
12c2112a
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
159 additions
and
0 deletions
+159
-0
checkNoisOddorEven.java
Basic programs/checkNoisOddorEven.java
+22
-0
findFactorial.java
Basic programs/findFactorial.java
+21
-0
findLargestAmongThree.java
Basic programs/findLargestAmongThree.java
+21
-0
helloworld.java
Basic programs/helloworld.java
+5
-0
isLeapYear.java
Basic programs/isLeapYear.java
+10
-0
multiply.java
Basic programs/multiply.java
+12
-0
readInput.java
Basic programs/readInput.java
+10
-0
swapNo.java
Basic programs/swapNo.java
+46
-0
vowelOrConsonent.java
Basic programs/vowelOrConsonent.java
+12
-0
No files found.
Basic programs/checkNoisOddorEven.java
0 → 100644
View file @
5eefb58a
import
java.util.Scanner
;
// first method using if-else
public
class
checkNoisOddorEven
{
static
public
void
main
(
String
[]
args
)
{
Scanner
input
=
new
Scanner
(
System
.
in
);
System
.
out
.
print
(
"Enter a number:"
);
int
val
=
input
.
nextInt
();
if
(
val
%
2
==
0
)
{
// if((val | 1) > val)
// if (val & 1 == 1)
System
.
out
.
println
(
"No. is even"
);
}
else
{
System
.
out
.
println
(
"No. is odd"
);
}
}
}
Basic programs/findFactorial.java
0 → 100644
View file @
5eefb58a
public
class
findFactorial
{
static
public
int
printFactorial
(
int
n
)
{
if
(
n
==
0
)
return
1
;
return
n
*
printFactorial
(
n
-
1
);
}
static
public
int
printFactorialIterative
(
int
n
)
{
int
res
=
1
;
for
(
int
i
=
2
;
i
<=
n
;
i
++
)
{
res
=
res
*
i
;
}
return
res
;
}
public
static
void
main
(
String
[]
args
)
{
int
factVal
=
6
;
int
x
=
printFactorial
(
factVal
);
System
.
out
.
println
(
"factorial of "
+
factVal
+
" is "
+
x
);
System
.
out
.
println
(
printFactorialIterative
(
factVal
));
}
}
Basic programs/findLargestAmongThree.java
0 → 100644
View file @
5eefb58a
public
class
findLargestAmongThree
{
static
int
largestOfThree
(
int
a
,
int
b
,
int
c
)
{
// return Math.max(a, Math.max(b, c));
return
a
>
b
?(
a
>
c
?
a:
c
):(
b
>
c
?
b:
c
);
}
public
static
void
main
(
String
[]
args
)
{
int
a
=
2
;
int
b
=
5
;
int
c
=
4
;
int
largest
=
0
;
if
(
a
>
b
)
{
largest
=
a
;
}
else
if
(
b
>
c
)
{
largest
=
b
;
}
else
{
largest
=
c
;
}
System
.
out
.
println
(
"Largest among three numbers is: "
+
largest
);
System
.
out
.
println
(
"Largest among three numbers is: "
+
largestOfThree
(
a
,
b
,
c
));
}
}
Basic programs/helloworld.java
0 → 100644
View file @
5eefb58a
public
class
helloworld
{
public
static
void
main
(
String
[]
arge
)
{
System
.
out
.
println
(
"Hello, World!"
);
}
}
Basic programs/isLeapYear.java
0 → 100644
View file @
5eefb58a
public
class
isLeapYear
{
public
static
void
main
(
String
[]
args
)
{
int
year
=
2020
;
if
(
year
%
4
==
0
)
{
System
.
out
.
println
(
"Leap Year"
);
}
else
{
System
.
out
.
println
(
"Not a Leap Year"
);
}
}
}
Basic programs/multiply.java
0 → 100644
View file @
5eefb58a
// java program to multiply two floating nos.
public
class
multiply
{
public
static
void
main
(
String
[]
args
)
{
float
a
=
2.5f
;
float
b
=
3.5f
;
float
c
=
a
*
b
;
System
.
out
.
println
(
c
);
}
}
Basic programs/readInput.java
0 → 100644
View file @
5eefb58a
import
java.util.Scanner
;
public
class
readInput
{
public
static
void
main
(
String
[]
args
)
{
Scanner
input
=
new
Scanner
(
System
.
in
);
System
.
out
.
print
(
"Enter a number:"
);
int
val
=
input
.
nextInt
();
System
.
out
.
println
(
val
);
}
}
Basic programs/swapNo.java
0 → 100644
View file @
5eefb58a
// public class swapNo {
// public static void main(String[] args) {
// int a = 2;
// int b = 3;
// int temp;
// System.out.println("values of a and b before swaping: ");
// System.out.println("a: "+ a);
// System.out.println("b: "+ b);
// temp = a;
// a = b;
// b = temp;
// System.out.println("values of a and b after swaping: ");
// System.out.println("a:"+ a);
// System.out.println("b:"+ b);
// }
// }
// we will make seprate function for swapping
public
class
swapNo
{
// static void swapValues(int a, int b) {
// int temp;
// temp = a;
// a = b;
// b = temp;
// swapValues(a, b);
// System.out.println("values of a and b after swaping:");
// System.out.println("a: " + a);
// System.out.println("b: " + b);
// }
static
void
swapWithoutTemp
(
int
a
,
int
b
)
{
a
=
a
*
b
;
b
=
a
/
b
;
a
=
a
/
b
;
System
.
out
.
println
(
"values of a and b after swaping:"
);
System
.
out
.
println
(
"a: "
+
a
);
System
.
out
.
println
(
"b: "
+
b
);
}
public
static
void
main
(
String
[]
args
)
{
int
a
=
3
;
int
b
=
8
;
// swapValues(a, b);
swapWithoutTemp
(
a
,
b
);
}
}
\ No newline at end of file
Basic programs/vowelOrConsonent.java
0 → 100644
View file @
5eefb58a
public
class
vowelOrConsonent
{
public
static
void
vowel_or_consonent
(
char
y
)
{
if
(
y
==
'a'
||
y
==
'e'
||
y
==
'i'
||
y
==
'o'
||
y
==
'u'
)
{
System
.
out
.
println
(
"It is vowel"
);
}
else
{
System
.
out
.
println
(
"It is consonent"
);
}
}
public
static
void
main
(
String
[]
args
)
{
vowel_or_consonent
(
'b'
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment