#### Question:

A special two-digit number is such that when the sum of the digits is added to the product of its digits, the result is equal to the original two-digit number.

**Example:**

Consider the number 59.Sum of digits = 5+9=14

Product of its digits = 5 x 9 = 45

Sum of the digits and product of digits = 14 + 45 = 59

Write a program to accept a two-digit number. Add the sum of its digits to the product of its digits. If the value is equal to the number input, output the message “special-two digit number” otherwise, output the message “Not a special two-digit number”.

#### Programming Code:

/** * The class Special_Q5_ICSE2014 inputs a 2 digit number and * checks whether it is a Special Two-digit number or not * @author : www.javaforschool.com * @Program Type : BlueJ Program - Java * @Question Year : ICSE 2014 Question 5 */ import java.io.*; class Special_Q5_ICSE2014 { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader (new InputStreamReader(System.in)); System.out.print("Enter a 2 digit number : "); int n = Integer.parseInt(br.readLine()); int first, last, sum, pro; if(n<10 || n>99) //Checking whether entered number is 2 digit or not System.out.println("Invalid Input! Number should have 2 digits only."); else { first = n/10; //Finding the first digit last = n%10; //Finding the last digit sum = first + last; //Finding the sum of the digits pro = first * last; //Finding the product of the digits if((sum + pro) == n) { System.out.println("Output : The number "+n+" is a Special Two-Digit Number."); } else { System.out.println("Output : The number is Not a Special Two-Digit Number."); } } } }

#### Output:

**1. **Enter a 2 digit number : 79

Output : The number 79 is a Special Two-Digit Number.

**2. **Enter a 2 digit number : 47

Output : The number is Not a Special Two-Digit Number.

Hi I like programmimg but I’m sometimes unable to understand it any method to help me in this context

This website contains great material ! However, in this particular program, won’t n be changed while operations are performed on it ? If so, won’t I have to copy n to some other variable so that I can compare it ?

No the value of ‘n’ will not change.

Thanks

It was very helpful

Keep it up

is the apc publishers good for class x

Yes good, but it has few mistakes in some programs. So teacher’s guidance is necessary.

How to score 100 in comp.. Do u suggest any good books?plz let me know what methods and books I need to adopt..thank u!

Hello Shivani,

Go through:

(1) http://www.guideforschool.com/368-top-10-tips-for-students-preparing-for-icseisc-examinations/

(2) http://www.guideforschool.com/1891649-advice-regarding-icse-computer-applications-examination/

(3) http://www.guideforschool.com/1902114-recommended-books-of-java-for-icse-and-isc-computer/

Great!loved this website.finding comp ..so much fun.!keep doing the great job! ðŸ˜€