Question

I need this in JAVA please: Design and implement a program (name it MinMaxAvg) that defines...

I need this in JAVA please:

Design and implement a program (name it MinMaxAvg) that defines three methods as follows: Method max (int x, int y, int z) returns the maximum value of three integer values. Method min (int X, int y, int z) returns the minimum value of three integer values. Method average (int x, int y, int z) returns the average of three integer values. In the main method, test all three methods with different input value read from the user. Document your code and properly label the input prompts and the outputs as shown below. Sample run 1: You entered: 20, 8, 12 Max value: 20 Min value: 8 Average value: 13 Sample run 2: You entered: 1, 2, 3 Max value: 3 Min value: 1 Average value: 2 Sample run 3: You entered: 10, 5, 25 Max value: 25 Min value: 5 Average value: 13

0 0
Add a comment Improve this question Transcribed image text
Answer #1
//MinMaxAvg.java
import java.util.Scanner;
public class MinMaxAvg {
    public static int max (int x, int y, int z){
        int result = x;
        if(result < y)
            result = y;
        if(result < z)
            result = z;
        return result;
    }

    public static int min (int x, int y, int z){
        int result = x;
        if(result > y)
            result = y;
        if(result > z)
            result = z;
        return result;
    }

    public static int average(int x, int y, int z){
        return (x+y+z)/3;
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x,y,z;
        x = scan.nextInt();
        y = scan.nextInt();
        z = scan.nextInt();

        System.out.printf("You entered: %d, %d, %d\n",x,y,z);
        System.out.println("Max value: "+max(x,y,z));
        System.out.println("Min value: "+min(x,y,z));
        System.out.println("Average value: "+average(x,y,z));
    }

}

Add a comment
Know the answer?
Add Answer to:
I need this in JAVA please: Design and implement a program (name it MinMaxAvg) that defines...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java code Exercise #1: (Java) Design and implement a program (name it MinMaxAvg) that defines...

    In Java code Exercise #1: (Java) Design and implement a program (name it MinMaxAvg) that defines three methods as follows: Method max (int x, int y, int z) returns the maximum value of three integer values. Method min (int X, int y, int z) returns the minimum value of three integer values. Method average (int x, int y, int z) returns the average of three integer values. In the main method, test all three methods with different input value read...

  • In Java Exercise #2: (Java) Design and implement a program (name it ComputeAreas) that defines four...

    In Java Exercise #2: (Java) Design and implement a program (name it ComputeAreas) that defines four methods as follows: Method squareArea (double side) returns the area of a square. Method rectangleArea (double width, double length) returns the area of a rectangle. Method circleArea (double radius) returns the area of a circle. Method triangleArea (double base, double height) returns the area of a triangle. In the main method, test all methods with different input value read from the user. Document your...

  • Design in Python (pseudocode) and implement (source code) a program (name it MyRectangle) that defines the...

    Design in Python (pseudocode) and implement (source code) a program (name it MyRectangle) that defines the following 3 methods: Method isValid() returns true if the sum of the width and height is greater than 30 Method Area() returns the area of the rectangle if it is a valid rectangle Method Perimeter() returns the perimeter of the rectangle if it is a valid rectangle The main method of MyRectangle prompts the user to enter the width and height of a rectangle...

  • Please do in Java as simply as possible :) Exercise #3: Design and implement a program...

    Please do in Java as simply as possible :) Exercise #3: Design and implement a program (name it ArrayMethods), that defines 4 methods as follows: int arrayMax(int[] arr) returns the maximum value in the an array int arrayMin(int[] arr) returns the minimum value in an array void arraySquared(int[] arr) changes every value in the array to its square (value²) void arrayReverse(int[] arr) reverses the array (for example: array storing 7   8   9 becomes 9   8   7 ) The program main...

  • Design and implement a Java program (name it ArrayMethods), that defines 4 methods as follows: int...

    Design and implement a Java program (name it ArrayMethods), that defines 4 methods as follows: int arrayMax (int [ ] arr) determines and returns the maximum value within an array int arrayMin (int [ ] arr) determines and returns the minimum value within an array void arraySquared (int [] arr) changes every value within the array to value2 void arrayReverse (int [ ] arr) reverses the array (for example: 7 8 12 becomes 2 18 7) Test your methods by...

  • PLEASE DO IN PSEUDOCODE; Design and implement a program (name it CheckPoint) that prompts the user...

    PLEASE DO IN PSEUDOCODE; Design and implement a program (name it CheckPoint) that prompts the user to enter the x-coordinate then y-coordinate of a point (in a Cartesian plane) as integer values. The program prints out the entered values followed by the location of the point on the plane. The possibilities for a point are: the origin point, on the x-axis, on the y-axis, in the first quadrant, in the second quadrant, in the third quadrant, or in the fourth...

  • Design and implement a Java program (name it ArrayMethods ), that defines 4 methods as follows:...

    Design and implement a Java program (name it ArrayMethods ), that defines 4 methods as follows: int arrayMax (int [ ] arr) determines and returns the ma ximum value within an array int arrayMin (int [ ] arr) determines and returns the minimum value within an array void arraySquared (int [ ] arr) changes every value within the array to value

  • In pseudocode only Design (pseudocode) a program (name it Occurrences) to determine whether two two-dimensional arrays...

    In pseudocode only Design (pseudocode) a program (name it Occurrences) to determine whether two two-dimensional arrays are equivalent or not. Two arrays are equivalent if they contain the same values in any order. The program main method defines two two-dimensional array of size 3-by-3 of type integer, and prompts the user to enter integer values to initialize the arrays. The main method calls method isEquivalent()that takes two two-dimensional arrays of integer and returns true (boolean value) if the arrays contain...

  • IN PYTHON WITHOUT USING: .APPEND/ .SORT/ INSERT / .SPLIT Program 1: Design (pseudocode) and implement (source...

    IN PYTHON WITHOUT USING: .APPEND/ .SORT/ INSERT / .SPLIT Program 1: Design (pseudocode) and implement (source code) a program (name it Occurrences) to determine whether two two-dimensional arrays are equivalent or not. Two arrays are equivalent if they contain the same values in any order. The program main method defines two two-dimensional array of size 3-by-3 of type integer, and prompts the user to enter integer values to initialize the arrays. The main method calls method isEquivalent()that takes two two-dimensional...

  • Python please! Exercise #3: Design and implement a program (name it ArrayMethods), that defines 4 methods...

    Python please! Exercise #3: Design and implement a program (name it ArrayMethods), that defines 4 methods as follows: int arrayMax(int[] arr) returns the maximum value in the an array int arrayMin(int[] arr) returns the minimum value in an array void arraySquared(int[] arr) changes every value in the array to its square (value²) void arrayReverse(int[] arr) reverses the array (for example: array storing 7 8 9 becomes 9 8 7 ) The program main method creates a single-dimensional array of length...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT