Computer Science, asked by llOgll, 4 days ago

In Java,
Write a program to input a number and find the sum of the sum and product of its digits using for loop
For Example : 458 is the number
4 + 5 + 8 = 17
4 × 5 × 8 = 160
17 + 160 = 177
And then tell whether it is a even number or odd number.
Ex : Like in this case it is odd

Don't spam​

Answers

Answered by kushagrav265
4

import java.util.*;

public class Java{

public static void main(String args[]){

Scanner sc = new Scanner(System.in);

float s = 0.0;

float p = 1.0;

int r,n;

System.out.println("Enter the value: ");

n=sc.nextInt();

do{

r = n%10;

s = s +r;

p = p*r;

n=n/10;

}while(n>0);

System.out.println("Sum ="+s);

System.out.println("Product ="+p);

}

if(n%2==0){

System.out.println("The number is even");

}

else{

System.out.println("The number is odd*);

}

}

IMPORTANT NOTE:-

if the last part of else doesn't work try this it might work

else if(n%2!=0){

System.out.println("The number is odd");

}

}

I am not a professional but this might work.

Hope this helps and plz mark me as brainliest :)

Answered by anaghmoghe38
1

Answer:

Write a program in Small Basicto input a number and display the productof its digits.

Explanation:

Similar questions