# Java program to find which of the three is the highest number, which of the three is the lowest one and to show how many odd and how many even number

• June 6th, 2009, 03:24 AM
chronoz13
Java program to find which of the three is the highest number, which of the three is the lowest one and to show how many odd and how many even number
just having some problems with this program, the program should compute the sum of the three numbers,
and i have to display the average of those three.,im done and im fine with it..

the problem is..
to display which of the three is the highest number, which of the three is the lowest one and to show how many odd , and how many even number that have been keyed in.

can anyone help with this simple algorithm?

this is the syntax

Code :

```import java.io.*;   public class threeNumbers   {   private static BufferedReader br= new BufferedReader(new InputStreamReader(System.in));   public static void main(String[] args)throws IOException   {   String number1,number2,number3; int num1,num2,num3,result,average;   System.out.print("Enter a number : "); number1=br.readLine(); num1=Integer.parseInt(number1);   System.out.print("Enter the second number : "); number2=br.readLine(); num2=Integer.parseInt(number2);   System.out.print("Enter the third number : "); number3=br.readLine(); num3=Ingteger.parseInt(number3);   result=num1+num2+num3; average=result/3;   System.out.println("The result for the three numbers is : " +result); System.out.println("The average for the three numbers is : " +average);   }   }```
// I dont have any more idea on what kind of algorith should i make to display that problem
display how many three numbers
• June 7th, 2009, 07:58 AM
Freaky Chris
Re: cant solve this one.. Selection structue problem and something more .. Help tnx
Just check them against each other to compare sizes then print out the results. Also just count how many are even you can check with %2 == 0

Chris
• June 8th, 2009, 09:58 PM
Truffy
Re: cant solve this one.. Selection structue problem and something more .. Help tnx
here's my code:

Code :

```  /** * * @author Truffy */ import java.io.*;   public class threeNumbers   {   private static BufferedReader br= new BufferedReader(new InputStreamReader(System.in));   public static void main(String[] args)throws IOException   {   String number1,number2,number3, odd, even; int num1,num2,num3,result,average,highest, lowest,b;   System.out.print("Enter a number : "); number1=br.readLine(); num1=Integer.parseInt(number1);   System.out.print("Enter the second number : "); number2=br.readLine(); num2=Integer.parseInt(number2);   System.out.print("Enter the third number : "); number3=br.readLine(); num3=Integer.parseInt(number3);   //det the odd or even if(num1%2 == 1){ System.out.println("odd number :" +num1); }else{ System.out.println("even3 number :" +num1);}   if(num2 % 2 == 1){ System.out.println("odd number :" +num2); }else {System.out.println("even number :" +num2);}   if(num3 % 2 == 1){ System.out.println("odd number :" +num3); }else{System.out.println("even number :" +num3);}   //determine the highest number if(num1>num2){ if(num1>num3){ System.out.println("Highest number is :" +num1); }else System.out.println("Highest number is :" +num3); }else{ if(num2>num3){ System.out.println("Highest number is :" +num2); }else{ System.out.println("Highest number is :" +num3); } }   //determine the lowest number if(num1<num2){ if(num1<num3){ System.out.println("Lowest number is :" +num1); }else System.out.println("Lowest number is :" +num3); }else{ if(num2<num3){ System.out.println("Lowest number is :" +num2); }else{ System.out.println("Lowest number is :" +num3); } }         result=num1+num2+num3; average=result/3;     System.out.println("The result for the three numbers is : " +result); System.out.println("The average for the three numbers is : " +average);     }   }```

hope it helps. :D
• June 10th, 2009, 12:32 AM
chronoz13
Re: cant solve this one.. Selection structue problem and something more .. Help tnx
tnx chris!and truffy! i just forgot how to use mod and how to get a number's remainder
hehe

anyway tnx again!!
• June 10th, 2009, 01:04 AM
Truffy
Re: cant solve this one.. Selection structue problem and something more .. Help tnx
Quote:

Originally Posted by chronoz13
tnx chris!and truffy! i just forgot how to use mod and how to get a number's remainder
hehe

anyway tnx again!!

no problem. :D