Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello, l have a doubt in java conditionals statements. Following is my code-
import java. until. Scanner;
public class Rudra {
public static void main (String [] args) {
int marks = 10;
if ( marks > 15 ) {
System.out. println( "your marks is good");
}else if ( marks < 15) {
System. out. println ("your marks is not good");
}
}
}

But l wanted to keep statement like if marks < 15 and also if age ==12so how to do that?? Please help me

What I have tried:

I tried doing this - if ( marks ==28, name == honey) {

But didn't worked, please help me..
Posted
Updated 17-Jul-21 23:34pm

All of the above shows that you need to learn the basic rules of the language. Go to The Java Tutorials Learning Paths[^] and work through them carefully. You will not learn by posting questions here.
 
Share this answer
 
Comments
[no name] 18-Jul-21 4:43am    
Thanks sir for your reply.
Another problem in your code
Java
if ( marks > 15 ) {
    System.out. println( "your marks is good");
}else if ( marks < 15) {
    System. out. println ("your marks is not good");
}

What happen when marks = 15 ?
There is no output !
 
Share this answer
 
Comments
[no name] 18-Jul-21 4:53am    
First of all, thanks for your reply sir. Sir l have used here conditional statements.

int marks = 15;
String name = "Rudra";

if ( marks == 15 )//but l wanted to keep two statements like if marks is 15 or name is Rudra then it will say true so how to keep two statements. I tried this-
if (marks ==15, name == Rudra)//here l tried to separate it with comma but didn't worked sir. I hope you will help me sir.
[no name] 18-Jul-21 5:00am    
Or in simple way, it means keeping two if statements so how to keep two if statements??
[no name] 18-Jul-21 5:37am    
int marks = 10;
if ( marks > 15 ) {
System.out. println( "your marks is good");
}else if ( marks < 15) {
System. out. println ("your marks is not good");
}
}
}
Try using the Java logical AND and OR operators: Conditionals and logic | Think Java | Trinket[^]
 
Share this answer
 
Comments
[no name] 18-Jul-21 5:35am    
Thanks and please provide me the syntax of that.
[no name] 18-Jul-21 5:36am    
It's my humble request
Richard MacCutchan 18-Jul-21 6:38am    
Go and follow the link I gave you and actually learn the language first.
OriginalGriff 18-Jul-21 7:14am    
You are kidding, right?
I give you a link to examples and an explanation, and you can't work out a single sImple line of code?

Tell me, why are you on this course at all?
[no name] 18-Jul-21 9:25am    
Brother sorry without going on that link l have commented you. Sorry for that actually I have not noticed that link. I went on that link and it helped me a lot. Thank you so much now l am able to complete my program. And l apologize for the inconvenience caused to you. Thanks a lot

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900