#I need help, you can see what I am trying what changes do i have to change.

31 messages · Page 1 of 1 (latest)

unkempt finch
#

import java.util.Scanner;
public class Main {

public static void main(String[] args) {
int grade;

Scanner reader = new Scanner(System.in);
System.out.println("Enter grade: ");
grade = reader.nextInt();

if (grade<101)
{
System.out.println("Invalid!");
}
else if (grade>75)
{
System.out.println("Passed!");
}
else if (grade>74)
{
System.out.println("Failed!");
}
else if (grade<59)
{
System.out.println("Invalid!");
}

}

}

coral sphinxBOT
#

This post has been reserved for your question.

Hey @unkempt finch! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

humble beacon
#

You have the wrong sign on your failed else if

unkempt finch
#

what do i have to change

humble beacon
#

I think it should be if(grade < 75)

#

But then it would print failed even if less then 59

unkempt finch
#

not working

#

it printed invalid

humble beacon
#

So you should also have your invalid ifs first

#

Oh, you have if(grade < 101) instead of if(grade > 101)

unkempt finch
#

ok

#

im trynna do is if it exceeds to 100 it should be invalid

#

if its below 60 it should be invalid

#

if its 74 below it should be failed

#

if its 75 above its pass

#

but every time I keep failing and keeps giving random answers

#

what do i need to change?

#

any ideas?

humble beacon
#

Use <=/>= instead of </>

unkempt finch
humble beacon
#

Yes, as you have it rn it won’t return anything on 74 or 75

#

And 100

#

But this specifically won’t fix that

unkempt finch
#

can u type it out for example

humble beacon
#

Try if (grade > 100 || grade < 60) System.out.println("Invalid!"); else if (grade >= 75) System.out.println("Passed"); else System.out.println("Failed!");

humble beacon
#

Do you see why that would work better?

unkempt finch