//testing the volume class 

import java.io.*;


public class TestVolume
{
	public static void main (String args[]) throws IOException
	{
		int choice; // for switch 
		String s;
		String answer;
		int x;
		int y;
		int z;
		
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		do // use of do While
		{
			System.out.println("Enter a number 1 to find the volume of a cube\n" +
							   "Enter a number 2 to find the volume of a cuboid\n");
							   
			s=in.readLine();
			choice=Integer.parseInt(s);
			
		switch(choice)
			{
				case 1://cube
					  System.out.println("You have selected to find the volume of a cube");
					  System.out.flush();
					  System.out.println("Enter a number from 1 to 30 ");
					  s=in.readLine();
					  x=Integer.parseInt(s);//convert string to integer
					  Volume vi = new Volume(x);// create an instance of class Volume
					  System.out.println("The volume of a cube with side =" + x+" is " + vi.getCubeVolume());
					  System.out.flush();//clear the stream buffer
					  
					  break;
					  
			    case 2: //cuboid
			    	  System.out.println("You selected to find the volume of a cuboid ");
			    	  System.out.println("Enter a whole number for the length of cuboid ");
			    	  System.out.flush();
			    	  s=in.readLine();
			    	  x=Integer.parseInt(s);
			    	  System.out.println("Enter a whole number for the width of cuboid ");	  
					  s=in.readLine();
					  y=Integer.parseInt(s);
					  System.out.println("Enter a whole number for the height of cuboid ");	
					  s=in.readLine();
					  z=Integer.parseInt(s);
					  Volume v2= new Volume(x,y,z);
					  System.out.println("The volume of a cuboid with length " + x + " width " + y + " and height " + z + " is " + v2.getCuboidVolume());
					  System.out.flush();
					  
					  break;
					  
				default:
					  System.out.println("Enter 0,1,2,3 - please!");
					  System.out.flush();
					  break;
					  
		}
		
		//the user can choose to continue or stop 
		System.out.println("Do you want to continue? If yes enter Y or to quit anything else");
		System.out.flush();
		answer=in.readLine();
	}
		
	while(answer.equalsIgnoreCase("Y"));
	}
}					  