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

Thank you Develop a program that has the following three methods: 1. int median(

ID: 3811067 • Letter: T

Question

Thank you

Develop a program that has the following three methods: 1. int median(int x, int y, int z) that calculates the median of three integers. 2. int mean(int x, int y, int z) that calculates the average of three integers, rounding the result to the nearest integer. 3. The main method that repetitively accepts three integers and states whether the median of the three is larger than the mean, smaller than the mean, or equal to the mean until the three integers accepted are the same. The main method calls the method median to get the median of three integers, and calls the method mean to get the mean of the three integers.

Explanation / Answer

HI, Please find my implementation.

import java.util.Scanner;

public class Median {

  

   public static int median(int x, int y, int z){

      

       int median = x;

      

       if(x <= y && y <= z)

           median = y;

       else if(y <= x && x <= z)

           median = x;

       else

           median = z;

      

       return median;

   }

  

   public static int mean(int x, int y, int z){

      

       float mean = (x+y+z)/3.0f;

      

       return Math.round(mean);

   }

  

   public static void main(String[] args) {

      

       Scanner sc = new Scanner(System.in);

      

       System.out.print("Enter three integers: ");

       int x = sc.nextInt();

       int y = sc.nextInt();

       int z = sc.nextInt();

      

       System.out.println("Median: "+median(x, y, z));

       System.out.println("Mean: "+mean(x, y, z));

      

   }

}

/*

Sample run:

Enter three integers: 4 1 2

Median: 2

Mean: 2

Enter three integers: 23 24 25

Median: 24

Mean: 24

Enter three integers: 24 23 25

Median: 24

Mean: 24

Enter three integers: 25 23 24

Median: 24

Mean: 24

*/

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