Skip to content

Commit

Permalink
Merge pull request #2163 from sumitchouhan13/my-new-branch
Browse files Browse the repository at this point in the history
Adds Java programs
  • Loading branch information
fineanmol authored Oct 3, 2022
2 parents 866ff88 + 87a932b commit 7fcbb60
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions java programs/largest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

import java.util.*;

public class LargestNumber {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int count = 1, max = Integer.MIN_VALUE;
while (true) {
System.out.println("Enter a Number : ");
int input = sc.nextInt();
if (input > max) {
max = input;
count = 1;
} else if (max == input) {
count++;
}
if (input == 0) {
System.out.println("The greatest number is : " + max + " and the occurence is : " + count);
break;
}
}
sc.close();
}

}

0 comments on commit 7fcbb60

Please sign in to comment.