To accept 3 number and find max among three number(using && for checking multiple experssion)

Please help me, I am a beginner in this discipline, and I hope I explain the problem

To accept 3 number and find max among three number(using && for checking multiple experssion)

Please help me, I am a beginner in this discipline, and I hope I explain the problem

Good starting point would be provide what you did so far and take it from there...

Good starting point would be provide what you did so far and take it from there...

Thank you very much if you have no sites to help me, especially for Mptidin I ask you to provide assistance

To accept 3 number and find max among three number(using && for checking multiple experssion)

Please help me, I am a beginner in this discipline, and I hope I explain the problem

Well your suppose to show some of your own work but here's the method for that problem. You will have to create the main method yourself if you want to implement it.

public static int findMax(int a, int b, int c)
	{
		if(a > b && a > c){
			System.out.println(a+" is the largest number");
			return a;
		}else if(b > a && b > c){
			System.out.println(b+" is the largest number");
			return b;
		}else
			System.out.println(c+" is the largest number");
			return c;
	}

Well your suppose to show some of your own work but here's the method for that problem. You will have to create the main method yourself if you want to implement it.

public static int findMax(int a, int b, int c)
	{
		if(a > b && a > c){
			System.out.println(a+" is the largest number");
			return a;
		}else if(b > a && b > c){
			System.out.println(b+" is the largest number");
			return b;
		}else
			System.out.println(c+" is the largest number");
			return c;
	}

Nice attempt for a good reply, although I dread to think what will happen when Eman1 is asked to find the max or min not from a total of 3 numbers but from a list of N numbers.

Try to give answers that enable the poster to write some code in their own.

Nice attempt for a good reply, although I dread to think what will happen when Eman1 is asked to find the max or min not from a total of 3 numbers but from a list of N numbers.

Try to give answers that enable the poster to write some code in their own.

They asked for help for an answer that accepted 3 numbers so I gave it to them. If they asked for the max or min for a list of n I would have helped :D
I'll try to give more hints next time and not the full code. Cheers mate :P

Nice attempt for a good reply, although I dread to think what will happen when Eman1 is asked to find the max or min not from a total of 3 numbers but from a list of N numbers.

Try to give answers that enable the poster to write some code in their own.

Well I thought about a list of n and came up with something. The program asks the user how many numbers they want to enter. It uses that number as the length of the array. This is code I actually created for another program but it can be applied here. I have outlined the method below:

public static void smallandLarge(int[] nums)	

// Determine the largest and smallest value in the array
		{	
			int largest_num = nums[0]; 		
// Initially assign largest number value to value of array position 0
			int smallest_num = nums[0];
			
			for(int i=1;i< nums.length;i++)	
// Work through the array
			{
				if(largest_num < nums[i])
					largest_num = nums[i];		
// Assign the value to largest if number is greater than previous number
				else if(smallest_num > nums[i])
					smallest_num = nums[i];
			} 
			
			System.out.print("\nLargest Number : "+largest_num);
			System.out.print("\nSmallest Number : "+smallest_num);
		
		}// end smallandLarge method

So what you think javaAddict

This question has already been answered. Start a new discussion instead.