Professional Documents
Culture Documents
A special two-digit number is such that when the sum of its 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 digits = 5 * 9 = 45
Sum of the sum of 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, then display the
message "Special two—digit number" otherwise, display the message "Not a
special two-digit number".
Java Java Iterative Stmts ICSE
210 Likes
ANSWER
import java.util.Scanner;
https://www.knowledgeboat.com/question/a-special-two-digit-number-is-such-that-when-the-sum-of-its-digits-is--12393456748830970?studylist=n… 1/7
10/11/23, 2:28 PM A special two-digit number is such that when the sum of its digits is | KnowledgeBoat
while (num != 0) {
int digit = num % 10;
num /= 10;
digitSum += digit;
digitProduct *= digit;
count++;
}
if (count != 2)
System.out.println("Invalid input, please enter a 2-digit number");
else if ((digitSum + digitProduct) == orgNum)
System.out.println("Special 2-digit number");
else
System.out.println("Not a special 2-digit number");
}
}
OUTPUT
BlueJ output of A special two-digit number is such that when the sum of its 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 digits = 5 * 9 = 45 Sum of the sum of 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, then display the
message "Special two—digit number" otherwise, display the message "Not a special two-digit number".
Answered By
80 Likes
https://www.knowledgeboat.com/question/a-special-two-digit-number-is-such-that-when-the-sum-of-its-digits-is--12393456748830970?studylist=n… 2/7
10/11/23, 2:28 PM A special two-digit number is such that when the sum of its digits is | KnowledgeBoat
https://www.knowledgeboat.com/question/a-special-two-digit-number-is-such-that-when-the-sum-of-its-digits-is--12393456748830970?studylist=n… 3/7
10/11/23, 2:28 PM A special two-digit number is such that when the sum of its digits is | KnowledgeBoat
https://www.knowledgeboat.com/question/a-special-two-digit-number-is-such-that-when-the-sum-of-its-digits-is--12393456748830970?studylist=n… 4/7
10/11/23, 2:28 PM A special two-digit number is such that when the sum of its digits is | KnowledgeBoat
https://www.knowledgeboat.com/question/a-special-two-digit-number-is-such-that-when-the-sum-of-its-digits-is--12393456748830970?studylist=n… 5/7
10/11/23, 2:28 PM A special two-digit number is such that when the sum of its digits is | KnowledgeBoat
STUDYLIST
COMPANY
https://www.knowledgeboat.com/question/a-special-two-digit-number-is-such-that-when-the-sum-of-its-digits-is--12393456748830970?studylist=n… 6/7
10/11/23, 2:28 PM A special two-digit number is such that when the sum of its digits is | KnowledgeBoat
About Us
Contact Us
Privacy Policy
Terms of Service
https://www.knowledgeboat.com/question/a-special-two-digit-number-is-such-that-when-the-sum-of-its-digits-is--12393456748830970?studylist=n… 7/7