Source code for BattingAverageExample.java:

public class BattingAverageExample
{
	public static void main(String args[])
	{
		// BattingAverageExample
		int hits = 40;
		int atBats = 100;
		double battingAverage = (double) hits / (double) atBats;
		System.out.println(battingAverage);
	}
}

Output from BattingAverageExample.java:

0.4

--- Output Ends ---

NOTE:

You are reading previously generated output. You are not currently running the BattingAverageExample application at the momement. You need to compile and run the source code first.

To run this program:


Authors: Kevin Chu and Eric Brower
Copyright 2000 Prentice Hall PTR