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

é Chrome File Edit View History Bookmarks People Window Help 8 21% D Wed Nov 9 1

ID: 3937304 • Letter: #

Question

é Chrome File Edit View History Bookmarks People Window Help 8 21% D Wed Nov 9 11:29:43 AM a e EE V Live Breaking News Video Josh ak Lab Assignments Mod 6-Chex Computer Science Tutors I Chc x nt https:// 10367 4/viewContent/18397105/View?ou 1103674 kennesaw.view.usg.edu i Apps Bookmarks Apple YouTube home E Watch Live Sports V DestinyLFG.Net IT om DestinyTracker De E Microsoft Device S D Watch Game Thron KENNESAW Programming Principles I Section 16 Fall Semester 2016 CO STATE UNIVERSITY course Home Li Content Discussions Assignments L? Quizzes a Other Classlist Grades Lab Assignments Mod 6-Ch6 Table of Contents Chapter 6 Lab Assignments Mod 6-Ch6 Program 2 Design and implement a Java program (name it MinMaxAvg) that defines three methods as follows Method max (int x, inty, int z) determines and returns the maximum value of three integer values Method min (int X, inty, 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 Average value 13 33333333333

Explanation / Answer

MinMaxAvg.java

import java.util.Scanner ;

public class maxminavg

{

public static void main( String args[ ])

{

Scanner scnr= new Scanner(System.in);

System.out.println("please enter three numbers to find maximum");

int a=scnr.nextInt();

int b=scnr.nextInt();

int c=scnr.nextInt();

if((a>b)&&(a>c))

{

System.out.printf("Between %d and %d and %d , maximum =%d ", a,b,c,a);

}

else

{

if((b>a)&&(b>c))

{

System.out.printf("Between %d and %d and %d , maximum =%d ", a,b,c,b);

}

else

{

System.out.printf("Between %d and %d and %d , maximum =%d ", a,b,c,c);

}

}

System.out.println("please enter three numbers to find minimum");

int x=scnr.nextInt();

int y=scnr.nextInt();

int z=scnr.nextInt();

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

{

System.out.printf("Between %d and %d and %d , minimum =%d ", x,y,z,,x);

}

else

{

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

{

System.out.printf("Between %d and %d and %d , minimum =%d ", x,y,z,y);

}

else

{

System.out.printf("Between %d and %d and %d , minimum =%d ", x,y,z,z);

}

}

System.out.println("please enter three numbers to find average");

int p=scnr.nextInt();

int q=scnr.nextInt();

int r=scnr.nextInt();

float avg=0;

avg=(p+q+r)/3;

System.out.printf("Average of %d and %d and %d is =%f",p,q,r,avg);

}

}

/*here using Scanner class added in java1.5 to read user input from console.

*/