Skip to content

Commit 947b1bf

Browse files
authored
src
1 parent 91d04b6 commit 947b1bf

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

โ€Žsrc/codeup100/c1039.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package codeup;
2+
3+
import java.util.Scanner;
4+
5+
public class c1039 {
6+
public static void main(String[] args){
7+
8+
Scanner sc = new Scanner(System.in); // Scanner ๊ฐ์ฒด ์ƒ์„ฑ
9+
10+
// ๋ฒ”์œ„ : -2147483648 ~ -2147483648
11+
System.out.print("์ฒซ๋ฒˆ์งธ ์ •์ˆ˜ ์ž…๋ ฅ: ");
12+
long num1 = sc.nextLong();
13+
long num2 = 0;
14+
15+
if( num1 < -2147483648L || num1 > 2147483648L ) { // num1์ด ๋ฒ”์œ„ ๋ฐ–
16+
System.out.println("๋ฒ”์œ„ ์•ˆ์˜ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.");
17+
18+
}else{ // num1์ด ๋ฒ”์œ„ ๋‚ด
19+
System.out.print("๋‘๋ฒˆ์งธ ์ •์ˆ˜ ์ž…๋ ฅ: ");
20+
num2 = sc.nextLong();
21+
22+
if( num2 < -2147483648L || num2 > 2147483648L ) { // num2์ด ๋ฒ”์œ„ ๋ฐ–
23+
System.out.println("๋ฒ”์œ„ ์•ˆ์˜ ์ •์ˆ˜๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.");
24+
25+
}else{
26+
sc.close();
27+
long sum = num1 + num2;
28+
System.out.println(sum);
29+
}
30+
}
31+
}
32+
}

0 commit comments

Comments
ย (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy