-2
I have an exercise in Java
where the program must read two numbers typed by the user and it should tell me which one!
Then there’s no way I can just use IF
right? I should also use the ELSE
?
Yes are exercises of DESVIO DE CONDICIONAL
-2
I have an exercise in Java
where the program must read two numbers typed by the user and it should tell me which one!
Then there’s no way I can just use IF
right? I should also use the ELSE
?
Yes are exercises of DESVIO DE CONDICIONAL
2
You can do it like this:
import java.util.Scanner;
public static void main(String[] args)
{
Scanner entrada = new Scanner(System.in);
int a,b;
System.out.println("A :");
a=entrada.nextInt;
System.out.println("B :");
b=entrada.nextInt;
if(a>b)
{
System.out.println("A é maior com valor:"+a);
}else if(b>a)
{
System.out.println("B é maior com valor:"+b);
}else
{
System.out.println("Os números são iguais com valor:"+a);
}
}
First insert the two numbers and after input, compare using if, Else if and Else...
Browser other questions tagged java if condition else
You are not signed in. Login or sign up in order to post.
With a
if..else
you can solve the exercise.– Valdeir Psr
our what my head I forgot of if! Thank you
– Carol M
Hi @Carolm posted the code, I hope I helped!
– Maurício Z.B