Computer Science, asked by agrawalshaan700, 3 days ago

fill in the blank for

write a program to input any no of 2 digit then find the sum of the no and it's reverse no . finally print no reverse no and the value of sum​

Answers

Answered by parthbansal448
0

Answer:

KnowledgeBoat Logo

Computer Applications

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

59 Likes

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;

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");

Similar questions