Ask Question
20 October, 03:52

Write a (java) program with a class called Sum1, using a while loop to add 10 numbers entered from the key-board.

Hint

the program has three variables

1 - number

2 - sum

3 - count

+5
Answers (1)
  1. 20 October, 04:28
    0
    This is a java program with a class called Sum1.

    Explanation:

    While loop is used to add 10 number.

    import java. util. Scanner;

    public class Sum 1

    {

    public static void main (String args[])

    {

    int number, count, sum = 0;

    Scanner s = new Scanner (System. in);

    System. out. print ("Enter the number:");

    number = s. nextInt ();

    while (number > 0)

    {

    count = number % 10;

    sum = sum + n;

    number = number / 10;

    }

    System. out. println ("Sum of Digits:"+sum);

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a (java) program with a class called Sum1, using a while loop to add 10 numbers entered from the key-board. Hint the program has ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers