Write a program that accepts numbers from the user till the user enters zero. Find out the
maximum and minimum number entered and display the result.
Answers
Answer:
sorry iska uttar nahi pta h
Answer:
package com.company;
import javax.swing.text.html.MinimalHTMLWriter;
import java.util.Scanner;
public class max_min {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num;
int max;
int min;
char c;
max = Integer.MIN_VALUE;;
min=Integer.MAX_VALUE;;
do {
System.out.println("ENTER ANY NUMBER");
num = sc.nextInt();
if (num > max) {
max = num;
}
if (num < min) {
min = num;
}
System.out.println("DO YOU WANT TO CONTINUE ?");
c=sc.next().charAt(0);
}while (c == 'y' || c== 'Y');
System.out.println(max);
System.out.println(min);
}
}
Explanation: