Practise set of CHapter 9
package com.company;
class sphere{
private double radius;
private double height;
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
}
class rectangle2 {
private double length;
private double breadth;
public rectangle2() {
this.length =5 ;
this.breadth =4;
}
public rectangle2(double length, double breadth) {
this.length = length;
this.breadth = breadth;
}
public double getLength() {
return length;
}
public double getBreadth() {
return breadth;
}
}
// int height;
// int radius;
// public cylinder(int x, int y) {
// height=x;
// radius=y;
// }
// public double surfaceArea(){
// return 2*Math.PI*radius*(height+radius);
// }
// public double volume(){
// return Math.PI*radius*radius*height;
// }
// /* private int radius;
// private int height;
// // for radius
// public void setRadius(int r){
// radius=r;
// }
// public int getRadius(){
// return radius;
// }
// for height
// public void setHeight(int h){
// height=h;
// }
// public int getHeight(){
// return height;
// }
// public double surfaceArea(){
// return (2 *Math.PI * radius* height+ 2*Math.PI *radius*radius);
// }
// public double volume(){
// return (Math.PI*radius*radius*height);
// }
public class CWH_44_PractiseSet {
public static void main(String[] args) {
// cylinder prop=new cylinder();
// Problem 1
// prop.setRadius(9);
// System.out.println(prop.getRadius());
// prop.setHeight(12);
// System.out.println(prop.getHeight());
//// Problem 2
// System.out.println(prop.surfaceArea());
// System.out.println(prop.volume());
// Problem 3
// cylinder prop= new cylinder(5,6);
// System.out.println(prop.surfaceArea());
// System.out.println(prop.volume()
// );
// Problem 5
// rectangle2 r= new rectangle2(12,56);
// System.out.println(r.getLength());
// System.out.println(r.getBreadth());
// problem 6
sphere sc= new sphere();
sc.setHeight(8);
sc.setRadius(4);
System.out.println(sc.getHeight());
System.out.println(sc.getRadius());
}
}
Comments
Post a Comment