2. Consider the following java code. Draw the UML diagram for the class cubee.(5 Marks)
import java.util.Scanner;
public class class1_triangle {
public static void main(String[] args) {
cubee mycube= new cubee();
mycube.inputdata();
System.out.println("Area of a cube is " + mycube.get_area());
System.out.println("Perimeter of a cube is " + mycube.get_parameter());
}
}
class cubee
{
int width;
void inputdata()
{
System.out.println("Please enter width of a cube ");
Scanner input = new Scanner(System.in);
width = input.nextInt();
}
double get_area()
{
return (width * width*width);
}
double get_parameter()
{
return width*12;
}
}
No comments:
Post a Comment