Write a program with a function volume() which accepts three sides of a cube and returns its volume. Provide a default value of 1 for all the three sides of a cube. Call this function with zero, one, two and three arguments and display the volume returned in the main().
Answers
Answer:
import java util.* ;
import java util.* ;public class volume
import java util.* ;public class volume {
import java util.* ;public class volume { public static void main (string args [])
import java util.* ;public class volume { public static void main (string args []) {
import java util.* ;public class volume { public static void main (string args []) {int p , q , r , volume = 0 ;
import java util.* ;public class volume { public static void main (string args []) {int p , q , r , volume = 0 ;Scanner sc = new scanner (System.in) ;
System.out.println ("Enter the first side of cube") ;
System.out.println ("Enter the first side of cube") ;p=sc.nextInt() ;
System.out.println ("Enter the first side of cube") ;p=sc.nextInt() ;System.out.println ("Enter second side of cube");
System.out.println ("Enter the first side of cube") ;p=sc.nextInt() ;System.out.println ("Enter second side of cube");q=sc.nextInt();
System.out.println ("Enter the first side of cube") ;p=sc.nextInt() ;System.out.println ("Enter second side of cube");q=sc.nextInt();System.out.println ("Enter third side of cube") ;
System.out.println ("Enter the first side of cube") ;p=sc.nextInt() ;System.out.println ("Enter second side of cube");q=sc.nextInt();System.out.println ("Enter third side of cube") ;r=sc.nextInt();
System.out.println ("Enter the first side of cube") ;p=sc.nextInt() ;System.out.println ("Enter second side of cube");q=sc.nextInt();System.out.println ("Enter third side of cube") ;r=sc.nextInt(); volume = p*q*r ;
System.out.println ("Enter the first side of cube") ;p=sc.nextInt() ;System.out.println ("Enter second side of cube");q=sc.nextInt();System.out.println ("Enter third side of cube") ;r=sc.nextInt(); volume = p*q*r ; System.out.println ("Volume of the cube =" + volume + "cm^3") ;
System.out.println ("Enter the first side of cube") ;p=sc.nextInt() ;System.out.println ("Enter second side of cube");q=sc.nextInt();System.out.println ("Enter third side of cube") ;r=sc.nextInt(); volume = p*q*r ; System.out.println ("Volume of the cube =" + volume + "cm^3") ; }
System.out.println ("Enter the first side of cube") ;p=sc.nextInt() ;System.out.println ("Enter second side of cube");q=sc.nextInt();System.out.println ("Enter third side of cube") ;r=sc.nextInt(); volume = p*q*r ; System.out.println ("Volume of the cube =" + volume + "cm^3") ; } }