Thursday, July 16, 2020

Java Program On Sum Product And Appending Numbers


Take 10 numbers and calculate their sum and product. Finally generate a number where product is appended with the sum.

e.g: Sum=123

product = 23

Final number = 12323

import java.util.*;

class Num1

{

 Int i, sum=0, product=1, n, num;

String s;

Scanner sc=new Scanner(System.in);

void take()

{

for(i=0;i<10;i++)

{

System.out.print(“\nEnter value:”);

n=sc.nextInt();

sum=sum+n;

product=product*n;

}

S=String.valueOf(sum)+ String.valueOf(product);

num=Integer.parseInt(s);

}

public static void main(String args[])

{

Num1 ob=new Num1();

ob.take ();

}

 }

Other Programs On Numbers: CLICK HERE

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner