Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design and implement a Java program (name it MinMaxAvg) that defines three metho

ID: 3674588 • Letter: D

Question

Design and implement a Java program (name it MinMaxAvg) that defines three methods as follows: Method max (int x, int y, int z) determines and returns the maximum value of three integer values. Method min (int X, int y, int z) determines and returns the minimum value of three integer values. Method average (int x, int y, int z) determines and returns the average of three integer values. Test the methods with different input value read from the user (in the main method). Design the main method of your program such that it allows the user to re-run the program with different inputs (i.e., use a loop structure). Document your code, and organize and space the outputs properly. Use escape characters to organize the outputs. Sample output is: You entered: 20 8 12 Max Value: 20 Min value 8 Average value: 13.33333333333

Explanation / Answer

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class MinMaxAvg
{
public static void main(String[] args) throws Exception
{
System.out.println("Please enter your numbers.");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int count = 0;
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
int total = 0;
while (st.hasMoreTokens())
{
int Num = Integer.parseInt(st.nextToken());
if (Num > max)
{
max = Num;
// min = Integer.parseInt(st.nextToken());
}
if (Num < min)
{
min = Num;
// max = Integer.parseInt(st.nextToken());
}
// System.out.println("Min : " + min + " Max : " + max);
count++;
total += Num;
}
float average = (float) total / count;
System.out.println("The Average value is: " + average);
System.out.println("Maximum: " + max);
System.out.println("Minimum: " + min);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote