import java.util.Scanner;
public class IfTest0
{
public static void main(String[] args)
{
Scanner scan = new Scanner( System.in );
//Prompt Hits
System.out.print( "Enter number of hits > " );
int hitAmount = scan.nextInt();
System.out.println( "Number of hits is " + hitAmount );
//Promt at bats
System.out.print( "Enter number of at bats > " );
int atBats = scan.nextInt();
System.out.println( "Number of at bats is " + atBats );
int Average;
Average = (hitAmount/atBats);
if ( Average>0.300 )
{
System.out.println( "Eligible for All-Stars " );
}
else
{
System.out.println ( "Not eligible for All-Stars " );
}
}
}
So I'm trying to use an if/else statement to state that when the batting average is greater than .300 the player is eligible for all stars. What happens is that when I input the hits and at bats it always says the player is not eligible. But when the average equals one the player is eligible which I find very strange but I can't figure out what is wrong with my code.
Edit: I think I figured it out, I was using the / to divide which would give me a value of 0 I just need to figure out how to properly divide now I'm assuming.