0% found this document useful (0 votes)
28 views1 page

Java Assignment 3

This document contains code for two Java classes: 1) A Box class that defines a constructor to set the height, width, and depth of a box object based on user input, and includes a getVolume method to return the volume of the box. 2) A Calculator class with static powerInt and powerDouble methods that use Math.pow to calculate integer and double powers and return the results.

Uploaded by

Navya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views1 page

Java Assignment 3

This document contains code for two Java classes: 1) A Box class that defines a constructor to set the height, width, and depth of a box object based on user input, and includes a getVolume method to return the volume of the box. 2) A Calculator class with static powerInt and powerDouble methods that use Math.pow to calculate integer and double powers and return the results.

Uploaded by

Navya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Wipro Talent Next 2021

CLASSES AND OBJECT-ASSIGNMENT


1 class main {
public static double main(String[] args) {
double height;
double width;
double depth;
Box b=new Box();
Scanner s=new Scanner(System.in);
height=s.nextFloat();
width=s.nextFloat();
depth=s.nextFloat();
public Box(double h,double w,double d){
height=h;
width=w;
depth=d;
}
public double getVolume()
double volume = h * w * d;
return volume;
}
}

2 class Calculator {
public static void main(String[] args) {
Calculator.powerInt(1, 2);
Calculator.powerDouble(2, 2);
}

public static double powerDouble(double num1, double num2) {


return Math.pow(num1,num2);
}
public static int powerInt(int num1, int num2) {
return (int) Math.pow(num1,num2);
}
}

You might also like