-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2163 from sumitchouhan13/my-new-branch
Adds Java programs
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |