Find Key:
You are provided with 3 numbers : input1, input2 and input3.
Each of these are four digit numbers within the range >=1000 and <=9999.
i.e.
1000 <= input1 <= 9999
1000 <= input2 <= 9999
1000 <= input3 <= 9999
You are expected to find the Key using the below formula -
Key = (Hundreds digit of input1 x Tens digit of input2) - (Largest digit of input3)
For e..g. if input1 = 3521, input2=2452, input3=1352, then Key = (5 x 5) - 5 = 20
Assuming that the 3 numbers are passed to the given function, Complete the function to find
and return the Key.Full java code
Answers
Language used: Java Programming
Program:
import java.util.*;
public class Main
{
static int keyfinding(int input1, int input2, int input3)
{
input1=(input1/100)%10;
input2=(input2/10)%10;
int largest = 0;
while(input3 != 0)
{
int r = input3 % 10;
largest = Math.max(r, largest);
input3 = input3 / 10;
}
int key=(input1*input2)-largest;
return key;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int input1 = sc.nextInt();
int input2 = sc.nextInt();
int input3 = sc.nextInt();
System.out.println(keyfinding(input1, input2, input3));
}
}
Input:
3521
2452
1352
Output:
20
Learn more:
1. Write a program to check whether it is a Lead number or not in java .
brainly.in/question/15644815
2. Write a java program to input name and mobile numbers of all employees of any office. Using "Linear Search", search array of phone no. for a given "mobile number" and print name of employee if found, otherwise print a suitable message.
brainly.in/question/18217872
Answer: Java Program
Explanation:
import java.util.*;
public class Main {
static int findingKey(int input1, int input2, int input3){
input1=(input1/100)%10;
input2=(input2/10)%10;
int largest = 0;
while(input3 != 0){
int rem = input3 % 10;
largest = Math.max(rem, largest);
input3 = input3 / 10;
}
int key=(input1 * input2) - largest;
return key;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int input1 = sc.nextInt();
int input2 = sc.nextInt();
int input3 = sc.nextInt();
System.out.println(findingKey(input1, input2, input3));
}
}
#SPJ2