Menu
Home
Create New Paste
Archive
Contact
Sign In
Sign Up
×
Sign in
×
Sign in using social network
Facebook
Google
Sign in with your username
Username
Password
×
Sign up
×
Sign up using social network
Facebook
Google
Sign up with your email address
Username
Email
Full Name
Password
The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Java Sample
By Guest on 9th July 2023 10:54:07 AM | Syntax: JAVA | Views: 499
New paste
|
Download
|
Show/Hide line no.
|
Copy text to clipboard
import
java.util.Scanner
;
public
class
AddTwoNumbers2
{
public
static
void
main
(
String
[
]
args
)
{
int
num1, num2, sum
;
Scanner sc
=
new
Scanner
(
System
.
in
)
;
System
.
out
.
println
(
"Enter First Number: "
)
;
num1
=
sc.
nextInt
(
)
;
System
.
out
.
println
(
"Enter Second Number: "
)
;
num2
=
sc.
nextInt
(
)
;
sc.
close
(
)
;
sum
=
num1
+
num2
;
System
.
out
.
println
(
"Sum of these numbers: "
+
sum
)
;
}
}
Raw Paste:
import java.util.Scanner; public class AddTwoNumbers2 { public static void main(String[] args) { int num1, num2, sum; Scanner sc = new Scanner(System.in); System.out.println("Enter First Number: "); num1 = sc.nextInt(); System.out.println("Enter Second Number: "); num2 = sc.nextInt(); sc.close(); sum = num1 + num2; System.out.println("Sum of these numbers: "+sum); } }
Recent Pastes
Test.php
1 year 22 weeks 4 days 9 hours 43 mins and 3 secs ago
Javascript sample
1 year 22 weeks 4 days 9 hours 43 mins and 3 secs ago
Java Sample
1 year 22 weeks 4 days 9 hours 43 mins and 3 secs ago
Test Document
1 year 22 weeks 4 days 9 hours 43 mins and 3 secs ago
PHP Sample
1 year 22 weeks 4 days 9 hours 43 mins and 3 secs ago