Recent Changes - Search:

CS160

Class Wiki

Instructors



edit SideBar

Lab6Solution

import java.util.Scanner;

public class Lab6 {
	public static void main(String[] args) 
	{
		Scanner console = new Scanner(System.in);

		System.out.print("Enter 3 numbers:");

		double x = console.nextDouble();
		double y = console.nextDouble();
		double z = console.nextDouble();

		System.out.println("The numbers are: " + x + " " + y + " " + z);
		System.out.println("The max is: " + max(x,y,z));
		System.out.println("The avg is: " + average(x,y,z));
	}

	public static double max(double a, double b, double c)
	{
		return Math.max(a, Math.max(b, c));
	}

	public static double average(double a, double b, double c)
	{
		return (a + b + c)/3.0;
	}
}
Edit - History - Print - Recent Changes - Search
Page last modified on October 03, 2008, at 11:46 PM MST