| Home | JSP | EJB | JDBC | Java Servlets | WAP | Free JSP Hosting | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML | ||||
|
||||
|
|
||||
| Tutorial Categories: Ajax
| Articles
| JSP
| Bioinformatics
| Database
| Free
Books |
Hibernate
| J2EE
| J2ME
| Java
| JavaScript
| JDBC
| JMS
| Linux
| MS
Technology |
PHP
| RMI
| Web-Services
| Servlets
| Struts
| UML
|
|
||||||||||||||||||||||||||||||
|
Home | JSP | EJB | JDBC | Java Servlets | WAP | Free JSP Hosting | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs |
||||||||||||||||||||||||||||||
Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.
Copyright © 2007. All rights reserved.
Current Comments
12 comments so far (post your own) View All Comments Latest 10 Comments:there should be an else statment in the main else..
public static void main(String[] args)
{
int x=5,y=0,z=3;
if(x>y)
{
if(x>z)
System.out.println(x);
else
{
if(z>y)
System.out.println(z);
else
System.out.println(y);
}
}
else
{
if(y>z)
System.out.println(y);
else
System.out.println(z);
}
}
Posted by Champ on Sunday, 04.5.09 @ 01:03am | #86512
This is another type of example for finding the largest number.
class velu1
{
public static void main(String args[])
{
int a=3,b=1,c=4;
if (a>b && a>c)
{
System.out.println("a is greatest");
}
else
if (b>c && b>a)
{
System.out.println("b is greatest");
}
else
if (c>a && c>b)
{
System.out.println("c is greatest");
}
}
}
Posted by veluswamy on Saturday, 08.23.08 @ 22:41pm | #74656
For example,
If x = 2, y = 200 and z = 400
this program does not produce the output as it never compares y and z separately.
I think another line of code should be added as in:
class LargerNumber{
public static void main(String[] args) {
int x=2, y=70, z=3000;
if (x>y){
if (x>z){
System.out.println("x is greater");
}
else{
if(z>y){
System.out.println("z is greater");
}
else{
System.out.println("y is greater");
}
}
}
else if (y>z){
System.out.println("y is greater");
}
else
System.out.println("z is greater");
}
}
Posted by Anuradha Mundinamani on Saturday, 08.2.08 @ 16:46pm | #70536
in above this program we are initiating no to variables other than this declare only variables and compare and they should read the values at compilation time ao simply what is the syntax for input of charater or nos.
Posted by lavanya on Monday, 04.28.08 @ 22:27pm | #58083
thanks a lot
Posted by pankaj jha on Thursday, 02.7.08 @ 14:40pm | #47504
class greaternumber
{
public static void main(String[] args)
{
int x=100,y=200,z=12;
if (x>y && y>z)
{
System.out.println("x is the Greater number");
}
else if(z>x && z>y)
{
System.out.println ("Z is the larget number");
}
else
{
System.out.println("Y is the larger number");
}
}
}
Posted by mangalamalatkar on Wednesday, 04.25.07 @ 16:40pm | #14917
BEING FRIENDLY AM HAPPY THAT NOW I CAN DO JUST A THING WITH JAVA.IT TAKES ME MORE THAN 3 WEEKS NOW TRYING TO UNDERSTAND WHAT WAS BEING TOUGHT BUT TODAY &I MEAN THIS DAY AM CAPABLE....KEEP ON HELPING US..THANX A LOT
Posted by l'ness on Thursday, 04.12.07 @ 00:05am | #13911
If the task is display the largest number among 100 integers, then what would be the solution, should we folow IF condition or Loop or something else please send the coding or the logic if anyone could solve this?
Posted by Shajib on Thursday, 03.15.07 @ 23:02pm | #11839
please explain me about (string[] args) in the main method
Posted by pranitha on Tuesday, 02.20.07 @ 04:52am | #8421
Thank you very much for setting up the example and sharing the code. I feel there may be some redundancy after the first else statement.
Best Regards,
Kim
Posted by Kim Tran on Thursday, 02.1.07 @ 16:04pm | #5204
ya this example is too good , but if it is some what diffecult that will be better ok eny way thanks for this examples
Posted by sharath pawar on Tuesday, 01.23.07 @ 16:46pm | #4143
please give more explanation for the above example
Posted by visakh m g on Friday, 12.1.06 @ 14:13pm | #318