You are on page 1of 7

10/11/23, 2:28 PM A special two-digit number is such that when the sum of its digits is | KnowledgeBoat

Home / Java Numbe… / A special two-di…

Java Number Programs (ICSE Classes 9 / 10)

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

Prev All Questions Next


Rs 6,290 Rs 4,070 Rs 3,710 Rs 3,150

ANSWER

import java.util.Scanner;

public class KboatSpecialNumber


{
public void checkNumber() {

Scanner in = new Scanner(System.in);

System.out.print("Enter a 2 digit number: ");


int orgNum = in.nextInt();

int num = orgNum;


int count = 0, digitSum = 0, digitProduct = 1;

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

ICSE/ISC TEXTBOOK SOLUTIONS

Class - 6 Concise Biology Selina Solutions

Class - 6 Veena Bhargava Geography Solutions

Class - 6 Effective History & Civics Solutions

Class - 6 APC Understanding Computers Solutions

Class - 7 Concise Physics Selina Solutions

Class - 7 Concise Chemistry Selina Solutions

Class - 7 Dalal Simplified Middle School Chemistry Solutions

Class - 7 Concise Biology Selina Solutions

Class - 7 Living Science Biology Ratna Sagar Solutions

Class - 7 Around the World Geography Solutions

Class - 7 Veena Bhargava Geography Solutions

Class - 7 Effective History & Civics Solutions

Class - 7 APC Understanding Computers Solutions

Class - 8 Concise Physics Selina Solutions

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

Class - 8 Concise Chemistry Selina Solutions

Class - 8 Dalal Simplified Middle School Chemistry Solutions

Class - 8 Concise Biology Selina Solutions

Class - 8 Living Science Biology Ratna Sagar Solutions

Class - 8 Around the World Geography Solutions

Class - 8 Veena Bhargava Geography Solutions

Class - 8 Effective History & Civics Solutions

Class - 8 APC Understanding Computers Solutions

Class - 8 Kips Logix Computers Solutions

Class - 9 Concise Physics Selina Solutions

Class - 9 Concise Chemistry Selina Solutions

Class - 9 Dalal Simplified ICSE Chemistry Solutions

Class - 9 Concise Biology Selina Solutions

Class - 9 Total Geography Morning Star Solutions

Class - 9 Veena Bhargava Geography Solutions

Class - 9 Total History & Civics Solutions

Class - 9 APC Understanding Computers Solutions

Class - 9 Kips Logix Computers Solutions

Class - 10 ML Aggarwal Mathematics Solutions

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

Class - 10 Concise Physics Selina Solutions

Class - 10 Concise Chemistry Selina Solutions

Class - 10 Dalal Simplified ICSE Chemistry Solutions

Class - 10 Concise Biology Selina Solutions

Class - 10 Total Geography Morning Star Solutions

Class - 10 Veena Bhargava Geography Solutions

Class - 10 Total History & Civics Solutions

Class - 10 APC Modern History & Civics Solutions

Class - 10 APC Understanding Computers Solutions

Class - 10 Sumita Arora ICSE Computers Solutions

Class - 10 Kips Logix Computers Solutions

Class - 11 APC Understanding Computers Solutions

Class - 12 APC Understanding Computers Solutions


ICSE/ISC SOLVED QUESTION PAPERS

ICSE Class 10 Computers Solved 10 Yrs Question Papers

Sample Papers ICSE Class 10 Computer Applications

ICSE Class 10 Physics Solved 10 Yrs Question Papers

ICSE Class 10 Chemistry Solved 10 Yrs Question Papers

ICSE Class 10 Biology Solved 10 Yrs Question Papers

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

Class - 12 ISC Computer Science Solved Practical Papers

STUDYLIST

Java Pattern Programs

Java Series Programs

Java Number Programs (ICSE Classes 9 / 10)

Java Number Programs (ISC Classes 11 / 12)

Output Questions for Class 10 ICSE Computer Applications

Algorithms & Flowcharts for ICSE Computers

ICSE Class 8 Computers Differentiate Between the Following

CBSE TEXTBOOK SOLUTIONS

Class - 9 NCERT Geography Contemporary India 1 Solutions

Class - 9 Sumita Arora Computer Code 165 Solutions

Class - 10 NCERT Science Solutions

Class - 10 NCERT Geography Contemporary India 2 Solutions

Class - 10 Sumita Arora Computer Code 165 Solutions

Class - 10 Kips Cyber Beans Computer Code 165 Solutions

Class - 11 CBSE Sumita Arora Python Solutions

Class - 12 CBSE Sumita Arora Python Solutions

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

Copyright © KnowledgeBoat 2023

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

You might also like