So in math, a restriction can be set. For example 30<x<60. So I'm trying to do this in a Java else if statement. else if (x>30 && x<60) {, will that do the same thing. Because I did that in my program but I'm getting my desired output twice. I'm suspecting this is because of the conditions of my previous if statements. What can I do to fix my problem?
To give a bit more detail
if (x < 30) {
Print
} else if (x==30) {
Print
} else if (x >30 && x <60) {
Print
} else if (age==50)
Print
There is more to this but I haven't done it
As is if I enter in my x as 50 I'll get my desired result and it won't repeat
if enter any other number besides numbers above 50
If my x is 2, for example,
my desired results should be
when you are 30 years old the year will be
when you are 50 years old the year will be
when you are 80 years old the year will be
but when I run the application I get
when you are 30 years old the year will be
when you are 50 years old the year will be
when you are 80 years old the year will be
when you are 50 years old the year will be
when you are 80 years old the year will be
1 answer