Java Code Program for the given Question

Given three values of different data types. You are required to store these values in variables of corresponding data type and output them. Input: The first line of input contains integer T denoting the number of test cases. For each test case, there will be three space seperated values i.e Integer, String, Float.

Your Answer

import java.util.stream.LongStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
public class HelloWorld{ public static void main(String args[]) throws Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine(); int N = Integer.parseInt(line);
ArrayList<Integer> inputs = new ArrayList<Integer>();
for (int i = 0; i < N; i++)
{
inputs.add(Integer.valueOf(br.readLine()));
}
ArrayList<BigInteger> outputs = new ArrayList<BigInteger>();
for(Integer input : inputs)
{
outputs.add(factorial(input));
}
for(BigInteger result: outputs){ System.out.println(result);
}
}
private static BigInteger factorial(Integer input)
{
if(input == 1) return BigInteger.ONE;
return factorial(input - 1).multiply(new BigInteger(String.valueOf(input)));
}
}

Core Java

Didn't get the answer.
Contact people of Talent-Core Java directly by clicking here