Written by Chris Piech and Mehran Sahami
This demo shows a simple method that takes in two inputs and returns the average:
private double average(double a, double b)
public class AverageMethod extends ConsoleProgram { public void run() { println(average(4, 5)); println(average(10, 2)); println(average(-4.1, 9.8)); } private double average(double a, double b) { return (a + b) / 2; } }