All pastes #2092407 Raw Edit

Stuff

public java v1 · immutable
#2092407 ·published 2011-10-22 03:44 UTC
rendered paste body
import java.util.Scanner;/**A program to calculate the area of a box, given the length of 3 sides*/public class AreaOfBox{	/**	Prompt the user to input the length of a given side and check to make sure the value is acceptable, or ask again.  	@param side - The name of the side the prompt will ask for	@return the length of the side as a double	*/ 	public static double userPrompt(String side)	{		Scanner in = new Scanner(System.in);		double length = 0; 		while (length <=0)		{			System.out.print("What is the length of " + side + "?: "); 			length = in.nextDouble();						if (length <=0)			{				System.out.print("Input not accepted. Please use a number greater than zero. "); 			}		}		return length;	}		public static void main(String[] args)	{		double side1 = userPrompt("Side 1");		double side2 = userPrompt("Side 2");		double side3 = userPrompt("Side 3");				System.out.println("The total area of a box with sides " + side1 + " " + side2 + " " + side3 + " = " + (side1*side2*side3) + " units cubed."); 		}}