Write a program to input a set of any 10 integer numbers. Find the sum and product of the numbers. Join the sum and product to form a single number. Display the concatenated number. [Hint: let sum=245 and product = 1346 then the number after joining sum and product will be 2451346]
import java.util.Scanner;
public class ATS
{
public static void main(String[]args)
{
Scanner in = new Scanner(System.in);
System.out.println("Enter 10 integers");
long sum = 0, prod = 1;
for (int i = 0; i < 10; i++)
{
int n = in.nextInt();
sum += n;
prod *= n;
}
String s = Long.toString(sum) + Long.toString(prod);
System.out.println("Concatenated Number"+"\t"+s);
}
}
No comments:
Post a Comment