Please help. I am trying to find the batting average and also the on base percentage. My output ends up being 0.0 for both no matter the numbers i put in, but when i use a calculator i end up getting something different. Also in my instructions i am told to input the numbers as integer values and to round my output to the nearest thousandths place.
import java.io.*;
import java.util.*;
public class Prog52d
{
public static void main (String args[])
{
Scanner kbReader=new Scanner(System.in);
//input
System.out.println("Enter Player's Name");
String name=kbReader.next();
System.out.println("Enter Number of Times at bat.");
int timesAtbat=kbReader.nextInt();
System.out.println("Enter Number of Hits.");
int hits=kbReader.nextInt();
System.out.println ("Enter Number of Walks.");
int walks=kbReader.nextInt();
//calculates the batting average
double battingAverage=hits/timesAtbat;
battingAverage= Math.round(battingAverage*1000.0)/1000.0;
//calculates the on base percentage
double onBasepercentage= (hits+walks)/(timesAtbat);
onBasepercentage= Math.round(onBasepercentage*1000.0)/1000.0;
System.out.println("Player "+name+ " has a ");
System.out.println("batting average of " + battingAverage + " and");
System.out.println(" an On Base Percentage of " + onBasepercentage);
}
}