 ``` Machine Problem

Write a program that uses a loop to compute the sum of all odd digits of an input.  (For example, if the given number is  6741, the sum would be 7 + 1 = 8.)

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My mobile number here in the Philippines is 09173084360.

=================================================

Want to support my channel?

GCash Account

09173084360

Paypal

Patreon

Thank you very much for your support.

```
``````package demo;

//Write a program that uses a loop to compute the sum of all odd digits of an input.
//(For example, if the given number is  6741, the sum would be 7 + 1 = 8.)

import java.util.Scanner;

public class Test
{
public static void main(String[] args) {

Scanner input = new Scanner(System.in);

int display_result = 0;

System.out.print("\n\n");
System.out.print("\tSum of All Odd Numbers in Java");
System.out.println("\n");
System.out.print("\tGive a Number : ");
int num = input.nextInt();
int y = num;

while (num > 0) {
int digit = num % 10;
if (digit % 2 != 0) {
display_result += digit;
}
num /= 10;
}
System.out.println();
System.out.printf("\tThe Sum of %d odd digits is %d", y, display_result);
System.out.println("\n");
System.out.print("\tEnd of Program");
System.out.println("\n");
input.close();
}
}``````