Write a program in java to accept numbers from the user till the time user enters N. Print the highest and the lowest number and also print count of the numbers.(using while loop)
Answers
Answered by
1
Answer:
import java.util.*;
class Count
{
public static void main( )
{
Scanner I= new Scanner( System. in)
int highest=0;
int lowest=9999999;
int count=0;
String input;
System.out. println ("Enter value");
input=I. nextLine ( );
while( input. compareTo ("N")!=0)
{
int ch= Integer. parseInt (input);
if(ch> highest)
highest=ch;
else if(ch< lowest)
lowest=ch;
count++;
}
System.out. println(highest);
System.out.println(lowest);
System.out.println(count);
}
}
Similar questions
Physics,
6 months ago
Math,
6 months ago
Social Sciences,
6 months ago
Social Sciences,
1 year ago
Math,
1 year ago
Biology,
1 year ago
History,
1 year ago