Computer Science, asked by SuryanshRam, 12 days ago

Write a programme to accept a number.Check its a 2 digit number or not if its a 2 digit number then display the sum of the digits.And then display the square of the sum.Otherwise display square of the number.​

Answers

Answered by LoveyouDelhi
2

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++;

       }

Explanation:

Answered by MichhDramebaz
0

\huge \bold \color{orange}a \color{red}n \color{green}\color{blue}s \color {purple}w\color {pink}e\color{yellow}r\color{lime}

Newton's laws of motion relate an object's motion to the forces acting on it. In the first law, an object will not change its motion unless a force acts on it. In the second law, the force on an object is equal to its mass times its acceleration.

Similar questions