FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
My-Java-Journey/GreatestOfTwoNum.java at main · aayanshanand/My-Java-Journey · GitHub
aayanshanand
/
My-Java-Journey
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
4
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
My-Java-Journey
/
GreatestOfTwoNum.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
25 lines (19 loc) · 902 Bytes
Breadcrumbs
My-Java-Journey
/
GreatestOfTwoNum.java
Copy path
File metadata and controls
25 lines (19 loc) · 902 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import
java
.
util
.
Scanner
;
// Import Scanner class for user input
public
class
GreatestOfTwoNum
{
// Function to return the greater of two numbers
public
static
int
getGreater
(
int
a
,
int
b
) {
return
(
a
>
b
) ?
a
: (
a
<
b
) ?
b
:
a
;
// Using ternary operator
}
public
static
void
main
(
String
[]
args
) {
try
(
Scanner
scanner
=
new
Scanner
(
System
.
in
)) {
// Creating Scanner object for user input
// Asking user to enter first number
System
.
out
.
println
(
"Enter the value of a: "
);
int
a
=
scanner
.
nextInt
();
// Asking user to enter second number
System
.
out
.
println
(
"Enter the value of b: "
);
int
b
=
scanner
.
nextInt
();
// Printing the greater number
System
.
out
.
println
(
"The greater number is: "
+
getGreater
(
a
,
b
));
}
}
}
Back
|
FazBrowse Home
|
New Git URL