Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class lab1_3 {
- public static void main(String[] args) {
- boolean isNotCorrect = false;
- System.out.println("Данная программа позволяет узнать количество цифр , из которых состоит число");
- int number = 1;
- int colOfNumber = 1;
- do {
- try {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Введите число");
- number = scanner.nextInt();
- } catch (Exception e) {
- System.out.println("Введите корректное значение");
- isNotCorrect = true;
- }
- } while (isNotCorrect);
- do {
- if (number/10>1){
- colOfNumber=colOfNumber+1;
- number=number/10;
- }else colOfNumber=1;
- }while (number/10>1);
- System.out.println("Количество цифр " +colOfNumber);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement