The problem is this: The program does what it is supposed to until the final line. It is supposed to display an average, but the decimal value always displays ".0" instead of the correct value. I'm not getting any errors so I am at a loss. I read a little bit about locale issues, but I have another very simple program that displays a decimal value correctly.
Any help would be appreciated. I attached the code below.
Thanks
//CODE
import java.io.*;
import java.util.Scanner;
public class Lab1_5 {
public static void main(
String[] args) throws IOException {
Scanner keyboard = new Scanner(System.in);
//Declare variables
int yearOneWin;
int yearTwoWin;
int yearThreeWin;
int yearFourWin;
int yearFiveWin;
int totalWins;
double averageWins;
//User input
System.out.print("Enter the number of wins for year 1: ");
yearOneWin = keyboard.nextInt();
System.out.print("Enter the number of wins for year 2: ");
yearTwoWin = keyboard.nextInt();
System.out.print("Enter the number of wins for year 3: ");
yearThreeWin = keyboard.nextInt();
System.out.print("Enter the number of wins for year 4: ");
yearFourWin = keyboard.nextInt();
System.out.print("Enter the number of wins for year 5: ");
yearFiveWin = keyboard.nextInt();
//Calculate total wins
totalWins = yearOneWin + yearTwoWin + yearThreeWin + yearFourWin + yearFiveWin;
//Calculate average wins
averageWins = totalWins / 5;
//Display the average wins from all five years
System.out.println("The average number of wins over the past five years is " + averageWins + ".");
}
}