0% found this document useful (0 votes)
5 views3 pages

Java Programs for Key and Password Calculation

The document contains two Java programs. The first program calculates a key based on the first digit of two integers and the maximum digit of a third integer. The second program determines a password based on the frequency of digits in an array of five integers.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Java Programs for Key and Password Calculation

The document contains two Java programs. The first program calculates a key based on the first digit of two integers and the maximum digit of a third integer. The second program determines a password based on the frequency of digits in an array of five integers.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

//pprogram 1

import [Link].*;

public class Main

public static int findKey(int n1, int n2, int n3){

String s1=[Link](n1);

int t=[Link]([Link](0));

s1=[Link](n2);

int h=[Link]([Link](1));

int m=n3%10;

while(n3!=0){

if(m<n3%10){

m=n3%10;

n3=n3/10;

int key=(t*h)-m;

return key;

public static void main(String[] args) {

Scanner sc=new Scanner([Link]);

int n1=[Link]();

int n2=[Link]();

int n3=[Link]();

[Link](findKey(n1,n2,n3));

}
//program 2

import [Link].*;

public class Main

static int frequency(int n,int i){

int count=0;

while(n!=0){

if(n%10==i){

count+=1;

n=n/10;

return count;

public static int findPassword(int []a){

int p;

int s=0;

int u=0;

int n=0;

int flag=1;

int temp;

//int n1=0;

for(int i=0;i<5;i++){

flag=1;

temp=a[i];

n=frequency(temp,a[i]%10);

a[i]=a[i]/10;

while(a[i]!=0){

if(frequency(temp,a[i]%10)!=n){
flag=0;

break;

a[i]=a[i]/10;

if(flag==0)

u+=1;

else

s+=1;

p=(u*10)+s;

return p;

public static void main(String[] args) {

Scanner sc=new Scanner([Link]);

int a[]=new int[5];

for(int i=0;i<5;i++)

a[i]=[Link]();

[Link](findPassword(a));

You might also like