Menu
Question Index
...


Write a program to get the list of the numbers. The list should contain only the numbers which are divisible by input number and the sum of the digits of the number is equal to given input number. For eg. if the input number is 15, then 690 is divisible by 15 and the sum of digits (6 + 9 + 0) is also 15.
NOTE: The numbers in the output list should be even, odd or either depending upon the type of the number ('Even', 'Odd', 'All').
The input string is of the format 'Start Number-End Number-Input Number-Number Type'.

Input (String) Output(List)
20-2000-15-Even [690, 780, 870, 960, 1590, 1680, 1770, 1860, 1950]
2-1000-11-Odd [209, 407, 605, 803]
1-2000-21-All [399, 588, 777, 966, 1596, 1659, 1785, 1848, 1974]
1-1500-20-Even [](Empty)
500-1500-13-Odd [715, 1183, 1417]

class GetNumbersList

{    public static void main(String s[])
    {
        System.out.println("The list of the numbers are : " + getTheListOfNumbers("1-1000-15-Odd"));

    }


public static List<Integer> getTheListOfNumbers(String input) {
//Write code here to find the list of the numbers, where the number is divisible and sum of its digits is equal to given input number.
}

//If required, write any additional methods here
}

Doubts

Problems

Topic: Java ArrayList

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App