Pick the Lower Integer
Java
2012-02-05
Java_567
Pick the Lower Integer
Copy code
import java.util.Scanner;
//@author javanshir
public class PicktheLowerInteger {
public static void main
(String[] args
) {
int nmbr1
= (int)(Math.
random()*10);
int nmbr2
= (int)(Math.
random()*10);
int nmbr3
= (int)(Math.
random()*10);
if (nmbr1!=nmbr2 && nmbr2!=nmbr3 && nmbr1!=nmbr3){
System.
out.
print("What is the lowest of these three\n"+nmbr1
+" "+nmbr2
+" "+nmbr3
+" ?\n");
}
Scanner input
= new Scanner
(System.
in);
int answer = input.nextInt();
if(nmbr1>nmbr2)
if (nmbr3>nmbr2)
if ( answer == nmbr2 )
System.
out.
println("You are correct! The answer is "+nmbr2
+" !");
else System.
out.
println("You are wrong! The answer should be "+nmbr2
+" !");
else if ( answer == nmbr3 )
System.
out.
println("You are correct! The answer is "+nmbr3
+" !");
else System.
out.
println("You are wrong! The answer should be "+nmbr3
+" !");
else if(nmbr1>nmbr3)
if ( answer == nmbr3 )
System.
out.
println("You are correct! The answer is "+nmbr3
+" !");
else System.
out.
println("You are wrong! The answer should be "+nmbr3
+" !");
else if ( answer == nmbr1 )
System.
out.
println("You are correct! The answer is "+nmbr1
+" !");
else System.
out.
println("You are wrong! The answer should be "+nmbr1
+" !");
}
}
Recent comments: ( 0 )
Please loggin to leave a comment!!