Read different types of data from standard input, process them as shown in output format and print the answer to standard output.
/*
Problem Statement: Read different types of data from standard input, process them as shown in output format and print the answer to standard output.
Input format:
First line contains integer N.
Second line contains string S.
Output format:
First line should contain N x 2.
Second line should contain the same string S.
Constraints:
0≤N≤10
1≤|S|≤15 where |S|= length of string S
*/
import java.util.Scanner;
public class TestClass {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int number = 0;
String string = null;
int firstInput = sc.nextInt();
String secondInput = sc.next();
// apply constraints
if (firstInput >= 0 && firstInput <= 10) {
number = firstInput;
}
if (secondInput.length() >= 1 && secondInput.length() <= 15) {
string = secondInput;
}
System.out.println(number * 2);
System.out.println(string);
sc.close();
}
}
Problem Statement: Read different types of data from standard input, process them as shown in output format and print the answer to standard output.
Input format:
First line contains integer N.
Second line contains string S.
Output format:
First line should contain N x 2.
Second line should contain the same string S.
Constraints:
0≤N≤10
1≤|S|≤15 where |S|= length of string S
*/
import java.util.Scanner;
public class TestClass {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int number = 0;
String string = null;
int firstInput = sc.nextInt();
String secondInput = sc.next();
// apply constraints
if (firstInput >= 0 && firstInput <= 10) {
number = firstInput;
}
if (secondInput.length() >= 1 && secondInput.length() <= 15) {
string = secondInput;
}
System.out.println(number * 2);
System.out.println(string);
sc.close();
}
}
Comments
Post a Comment