Skip to content

pchp250g8-home-java-tutorials/java-console-isnumberdividesby3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IsNumberDividesBy3. Java tutorials. Console Application. Simple Input/Output. Algorithms. A console application project written in the Java programming language and implemented in the Apache NetBeans integrated environment. The Java platform provides simple input/output. Determining the sum of digits in a number entered from the keyboard. Answer to the question whether a given number is divisible by 3. The program does the following:

  1. Prompts the user for an integer.
  2. Sets the sum of digits variable to zero.
  3. Creates a temporary variable with an initial a positive value equal in magnitude to the number entered from the keyboard.
  4. The loop with precondition is executed: a) The value of the temporary variable is compared to zero. If its value is greater than zero, the loop continues executing; otherwise, it terminates. (Go to step 5) b) The sum of digits variable is incremented by modulo to 10. c) The temporary variable is divisible by 10.
  5. It is checked whether the resulting sum of the digits of the number is divisible by 3.
  6. The entered number and the sum of its digits are displayed on the screen.
  7. The answer to the question whether the given number is divisible by 3 is displayed on the screen.

IsNumberDividesBy3. Занятия по Java. Консольное приложение. Простой Ввод/вывод. Алгоритмы. Проект консольного приложения написан на языке программирования Java и реализован в интегрированной среде Apache NetBeans. Платформа Java. Простой ввод-вывод. Определение суммы цифр в числе, введённом с клавиатуры. Ответ на вопрос делится ли данное число на 3. Данная программа делает следующее:

  1. Запрашивает у пользователя ввод целого числа.
  2. Устанавливает переменную суммы цифр в значение равное нулю.
  3. Создаёт временную переменную с первоначальным положительным значением равным по модулю числу введённому с клавиатуры.
  4. Выполняется цикл с предусловием: a) Значение переменной сравнивается с нулём. Если оно больше нуля, цикл продолжает выполняться, в противном случае завершается (Переход к пункту 5). b) Сумма цифр увеличивается на остаток от деления значения временной переменной на 10. c) Времменая переменная делится на 10
  5. Проверяется делится ли полученная сумма цифр числа на 3.
  6. На экран выводится введённое число и сумма его цифр.
  7. На экран выводится ответ на вопрос делится ли данное число на 3.

About

IsNumberDividesBy3. Java tutorials. Console Application. Simple Input/Output. Algorithms.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages