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.
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...
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...
Hello. I have an assignment that is completed minus one thing, I can't get the resize...
Hello. I have an assignment that is completed minus one thing, I can't get the resize method in Circle class to actually resize the circle in my TestCircle claass. Can someone look and fix it? I would appreciate it! If you dont mind leaving acomment either in the answer or just // in the code on what I'm doing wrong to cause it to not work. That's all I've got. Just a simple revision and edit to make the resize...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...
Compile and execute the application. You will discover that is has a bug in it -...
Compile and execute the application. You will discover that is has a bug in it - the filled checkbox has no effect - filled shapes are not drawn. Your first task is to debug the starter application so that it correctly draws filled shapes. The bug can be corrected with three characters at one location in the code. Java 2D introduces many new capabilities for creating unique and impressive graphics. We’ll add a small subset of these features to the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • A) Assuming that ferrous ammonium sulfate hexahydrate is the limiting reagent in a reaction with ferrous...
    asked 4 minutes ago
  • Ross Hopkins, president of Hopkins Hospitality, has developed the tasks, durations, and predecessor relationships in the...
    asked 15 minutes ago
  • A trapezoidal channel is needed for a location where the bed slope is 0.008 ft/ft, discharge...
    asked 18 minutes ago
  • List and briefly explain each step in the ABCDE technique for examining irrational beliefs that contribute...
    asked 37 minutes ago
  • 1. Find the general solution of the first order linear differential equation: 2*x*dy/dx -y-3/sqrt(x)=0. sqrt() =...
    asked 59 minutes ago
  • Fairfield Homes is developing two parcels near Pigeon Fork, Tennessee. In order to test different advertising...
    asked 1 hour ago
  • . For each of the following questions, say whether the random process is reasonably a binomial...
    asked 1 hour ago
  • Please discuss why empathy is so important in light of current events. Please give specific examples
    asked 1 hour ago
  • Describe ONE thing you learned from either Peter singer or Tibor Machan author that compelled you...
    asked 1 hour ago
  • Global logistics firms such as DHL Supply Chain and Global Forwarding or C. H. Robinson Worldwide...
    asked 1 hour ago
  • Please match each factor in adoption of a new product or service to the best match...
    asked 2 hours ago
  • Fatty Acid Synthesis Assignment Explain how the activation of acetyl-CoA carboxylase prevents excess citrate in the...
    asked 2 hours ago