write a program to input a two digit number and display the greatest digit.
Answers
Answer:
The velocity of an object is the rate of change of its position with respect to a frame of reference, and is a function of time. Velocity is equivalent to a specification of an object's speed and direction of motion (e.g. 60 km/h to the north).
import java.util.Scanner;
public class KboatSpecialNumber
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter a 2 digit number: ");
int orgNum = in.nextInt();
if (orgNum < 10 || orgNum > 99) {
System.out.println("Invalid input. Entered number is not a 2 digit number");
System.exit(0);
}
int num = orgNum;
int digit1 = num % 10;
int digit2 = num / 10;
num /= 10;
int digitSum = digit1 + digit2;
int digitProduct = digit1 * digit2;
int grandSum = digitSum + digitProduct;
if (grandSum == orgNum)
System.out.println("Special 2-digit number");
else
System.out.println(
Hope it helps you keep smiling :)