-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path1.1 Input and Output statement.java
More file actions
51 lines (37 loc) · 1.03 KB
/
1.1 Input and Output statement.java
File metadata and controls
51 lines (37 loc) · 1.03 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
Write a program to take the 2 inputs of integer type from the user. Display the values separated by symbol ‘-’ if the values are positive otherwise display the message “Invalid Input”.
Input Format
Your program should take at least 2 inputs of integer type.
Constraints
Input should be positive integers
Output Format
Output should be the input values separated by ‘-‘ or “Invalid Input” message if any input is negative.
Sample Input 0
10
2
Sample Output 0
10-2
Sample Input 1
20
-10
Sample Output 1
Invalid Input
*/
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
if(a>0 && b>0)
{
System.out.print(a+"-"+b);
}
else
{
System.out.print("Invalid Input");
}
}
}