0% found this document useful (0 votes)
24 views

Max of Numbers With User Input

Uploaded by

AAsfaw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Max of Numbers With User Input

Uploaded by

AAsfaw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

/*

* To change this template, choose Tools | Templates


* and open the template in the editor.
*/

package rdg6b;

import java.util.Scanner;

/**
*
* @author user
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner input=new Scanner(System.in);
System.out.println("choose numbers from 0 to 5");
int n=input.nextInt();
switch(n){
case 2:
System.out.println("Enter two numbers: ");
int n21=input.nextInt();
int n22=input.nextInt();
System.out.printf("The max of %d and %d is
%d\n",n21,n22,TestMax.max(n21,n22));
break;
case 3:
System.out.println("Enter three numbers: ");
int n31=input.nextInt();
int n32=input.nextInt();
int n33=input.nextInt();
System.out.printf("The max of %d , %d and %d is
%d\n",n31,n32,n33,TestMax.max(n31,n32,n33));
case 4:
System.out.println("Enter four numbers: ");
int n41=input.nextInt();
int n42=input.nextInt();
int n43=input.nextInt();
int n44=input.nextInt();
System.out.printf("The max of %d , %d,%d and %d is
%d\n",n41,n42,n43,n44,TestMax.max(n41,n42,n43,n44));
case 5:
System.out.println("Enter five numbers: ");
int n51=input.nextInt();
int n52=input.nextInt();
int n53=input.nextInt();
int n54=input.nextInt();
int n55=input.nextInt();
System.out.printf("The max of %d,%d , %d,%d and %d is
%d\n",n51,n52,n53,n54,n55TestMax.max(n51,n52,n53,n54,n55));
default:
System.out.println("Invalid number!! ");
}
}

You might also like