Question

A point in the x-y plane is represented by its x-coordinate and y-coordinate. Design a class,...

  1. A point in the x-y plane is represented by its x-coordinate and y-coordinate. Design a class, pointType, that can store and process a point in the x-y plane. You should then perform operations on the point, such as setting the coordinates of the point, printing the coordinates of the point, returning thex-coordinate, and returning the y-coordinate. Also, write a program to testvarious operations on the point.
  1. x-y plane and you designed the class to capture the properties of a point in Part a), you must derive the class circleType from the class pointType. You should be able to perform the usual operations on the circle, such as setting the radius, printing the radius, calculating and printing the area and circumference, and carrying out the usual operations on the center. Also, write a program to test various operations on a circle.

  2. Every cylinder has a base and height, wherein the base is a circle. Design a class, cylinderTypethat can capture the properties of a cylinder and perform the usual operations on the cylinder. Derive this class from the class “circleTypedesigned inPart b). Some of the operations that can be performed on a cylinder are as follows: calculate and print the volume, calculate and print the surface area, set the height, set the radius of the base, and set the center of the base. Also, write a program to test various operations on a cylinder.
  3. Every circle has a center and a radius. Given the radius, we can determine the circle’s area and circumference. Given the center, we can determine its position in the x-y plane. The center of the circle is a point in the x-y plane. Design a class, “circleType, which can store the radius and center of the circle. Because the center is a point in the

Homework Answers

Answer #1

Note: Since the coding language is not specified I am using Java.

import java.util.Scanner;
import java.lang.Math;
class pointType{
    private int x;
    private int y;
    public pointType(int x,int y){
        this.x=x;
        this.y=y;
    }
    public int getX(){
        return x;
    }
    public int getY(){
        return y;
    }
}
class circleType extends pointType{
    private double radius;
    
    public circleType(int x,int y,double radius){
        super(x,y);
        this.radius=radius;
    }
    public double getRadius(){
        return radius;
    }
    public double area(double radius){
        return 3.14*radius*radius;
    }
    public double circumference(double radius){
        return 2*3.14*radius;
    }
    
}
class cylinderType extends circleType{
    private double baseRadius;
    private double height;
    public cylinderType(int x,int y,double baseRadius,double height){
        super(x,y,baseRadius);
        this.height=height;
    }
    public double getHeight(){
        return height;
    }
    public double volume(double baseRadius,double height){
        return 3.14*baseRadius*baseRadius*height;
    }
}
public class PrintMessage{
    public static void main (String[] args) {
        Scanner sc=new Scanner(System.in);
    //a.) POINT TYPE
        System.out.println("a.)POINT TYPE");
       System.out.print("Enter the X & Y coordinates of a point, by space separation(ex: 3 5): ");
        String str=sc.nextLine();
        String s[]=str.split(" ");
        int x=Integer.parseInt(s[0]);
        int y=Integer.parseInt(s[1]);
        pointType obj=new pointType(x,y);
        System.out.println("Point: "+obj.getX()+" "+obj.getY());
        double d=Math.sqrt(x*x+y*y);
        System.out.println("Distance of the point from origin is: "+String.format("%.2f",d));
    
    //b.) CIRCLE TYPE
        System.out.println("\n------------------------------------");
        System.out.println("b.)CIRCLE TYPE");
        System.out.print("Enter the X and Y coordinates of the center of circle by space separation(ex: 4,5): ");
        String str1=sc.nextLine();
        String s1[]=str1.split(" ");
        x=Integer.parseInt(s1[0]);
        y=Integer.parseInt(s1[1]);
        System.out.print("Enter the radius of the circle:");
        double r=sc.nextDouble();
        circleType circle=new circleType(x,y,r);
        System.out.println("Center of the circle: "+x+" "+y);
        System.out.println("Radius of the circle: "+circle.getRadius());
        System.out.println("Area of the circle: "+String.format("%.2f",circle.area(r)));
        System.out.println("Circumference of the circle: "+String.format("%.2f",circle.circumference(r)));
    
    //c.)CYLINDER TYPE
         System.out.println("\n------------------------------------");
        System.out.println("b.)CYLINDER TYPE");
        System.out.print("Enter the X and Y coordinates of the center of cylinder by space separation(ex: 4,5): ");
        sc.next();
        String str2=sc.nextLine();
        String s2[]=str.split(" ");
        x=Integer.parseInt(s2[0]);
        y=Integer.parseInt(s2[1]);
        System.out.print("Enter the base radius of the cylinder:");
        double br=sc.nextDouble();
        System.out.print("Enter the height of the cylinder:");
        double ch=sc.nextDouble();
        cylinderType cylinder=new cylinderType(x,y,br,ch);
         System.out.println("Center of the cylinder: "+x+" "+y);
        System.out.println("Base Radius of the cylinder: "+cylinder.getRadius());
        System.out.println("Volume of the cylinder: "+String.format("%.2f",cylinder.volume(br,ch)));

    //d.) CIRCLE TYPE IS SAME AS THE a.)
        
    }
}

Thank you! If you have any queries post it below in the comment section i will try my best to resolve your queries and if required i will add it to my answer.Give a upvote if you like it.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Java code Problem 1. Create a Point class to hold x and y values for a...
Java code Problem 1. Create a Point class to hold x and y values for a point. Create methods show(), add() and subtract() to display the Point x and y values, and add and subtract point coordinates. Tip: Keep x and y separate in the calculation. Create another class Shape, which will form the basis of a set of shapes. The Shape class will contain default functions to calculate area and circumference of the shape, and provide the coordinates (Points)...
Suppose the receiving stations X, Y, and Z are located on a coordinate plane at the...
Suppose the receiving stations X, Y, and Z are located on a coordinate plane at the point (3,7), (-15,-6), and (-7,2) respectively. The epicenter of an earthquake is determined to be 10 units from X, 13 units from Y and 5 units from Z. Where on the coordinate plane is the epicenter located? Find the coordinates of the epicenter. Please show work, I actually want to learn how to solve this problem.
A quarter circle of radius 432 mm lies on Quadrant II of a coordinate plane with...
A quarter circle of radius 432 mm lies on Quadrant II of a coordinate plane with reference radius at the origin. A rectangle is attached to the quarter circle at Quadrant I with base at the x-axis of width equal to 14.2 mm and height same as the radius of the quarter circle. Another rectangle with inverse dimension as the previous is attached to the quarter circle at Quadrant II. a. What is the moment of inertia (m^4) of the...
IN C++ - most of this is done it's just missing the bolded part... Write a...
IN C++ - most of this is done it's just missing the bolded part... Write a program that creates a class hierarchy for simple geometry. Start with a Point class to hold x and y values of a point. Overload the << operator to print point values, and the + and – operators to add and subtract point coordinates (Hint: keep x and y separate in the calculation). Create a pure abstract base class Shape, which will form the basis...
Three point of measurement coordinates are collected on a circle (X,Y,Z): P1(14,21,8), P2(45,22,8) and P3(65,19,8) (all...
Three point of measurement coordinates are collected on a circle (X,Y,Z): P1(14,21,8), P2(45,22,8) and P3(65,19,8) (all measurements in mm). Calculate the center of Y-Coordinate of the circle.
Must be C++ programming    The MyPoint class was created to model a point in a...
Must be C++ programming    The MyPoint class was created to model a point in a two-dimensional space. The MyPoint class has the properties x and y that represent x- and y-coordinates, two get functions for x and y, and the function for returning the distance between two points. Create a class named ThreeDPoint to model a point in a three-dimensional space. Let ThreeDPoint be derived from MyPoint with the following additional features: A data field named z that represents...
Assignment 3 Chapter 2: Algorithm Discovery and Design More about Pseudocode Design an algorithm that is...
Assignment 3 Chapter 2: Algorithm Discovery and Design More about Pseudocode Design an algorithm that is given a positive integer N and determines whether N is a prime number, that is, not evenly divisible by any value other than 1 and itself. The output of your algorithm is either the message ‘not prime’, along with a factor of N, or the message ‘prime ‘ Many excellent simulations of sorting algorithms are available, examine them if they have questions about this...
Let y = x 2 + 3 be a curve in the plane. (a) Give a...
Let y = x 2 + 3 be a curve in the plane. (a) Give a vector-valued function ~r(t) for the curve y = x 2 + 3. (b) Find the curvature (κ) of ~r(t) at the point (0, 3). [Hint: do not try to find the entire function for κ and then plug in t = 0. Instead, find |~v(0)| and dT~ dt (0) so that κ(0) = 1 |~v(0)| dT~ dt (0) .] (c) Find the center and...
Design a Java class named Polygon that contains:  A private int data field named numSides...
Design a Java class named Polygon that contains:  A private int data field named numSides that defines the number of sides of the polygon. The default value should be 4.  A private double data field named sideLength that defines the length of each side. The default value should be 5.0.  A private double data field named xCoord that defines the x-coordinate of the center of the polygon. The default value should be 0.0.  A private double...
IN JAVA Speed Control Problem: The files SpeedControl.java and SpeedControlPanel.java contain a program (and its associated...
IN JAVA Speed Control Problem: The files SpeedControl.java and SpeedControlPanel.java contain a program (and its associated panel) with a circle that moves on the panel and rebounds from the edges. (NOTE: the program is derived from Listing 8.15 and 8.16 in the text. That program uses an image rather than a circle. You may have used it in an earlier lab on animation.) The Circle class is in the file Circle.java. Save the program to your directory and run it...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT