Implement the following classes: Polygon numSide: int /* constructor */ /* accessor-mutator */ + area (): double + perimeter (): double Triangle sideA: double sideB: double sidec: double /* constructor */ /* accessor-mutator */ + area () : double + perimeter (): double Create an object for Triangle class and invoke area and perimeter method. Input Format Take triangle sides (sideA,sideB,sideC) as input from user. Constraints For Triangle, sideB+sideC > sideA
Q: Quiz Task: Create a class Student with following instance private variables and member functions:…
A: The answer is given below.
Q: Preliminaries • Write a Point class with two properties: r, y. Write required constructor, get &…
A: NOTE: As per the policy we can answer only one question at a time, kindly repost the other part to…
Q: create a class rectangle with attributes length and width both encapsulated, each of which defaults…
A: Program code: File name: "Rectangle.java" //import the required packages import…
Q: Design a class Circle with the following Private double data for radius One no arg constructor One…
A: //note: since the programming language is mentioned we are providing answer in cpp #include…
Q: This composition example contains classes Date, Employee and EmployeeTest .Class Date declares…
A: This composition example contains classes Date, Employee and EmployeeTest .Class Date declares…
Q: Create a class circle class with radius as data member. Create two constructors (no argument, and…
A: Class A class is user define interface which act as blueprint for creating objects and instances…
Q: Implement a class called BankAccount that is used to keep track of a bank account. This class will…
A: In the solution of given problem, we define the class BankAccount, with two private members id (int)…
Q: Slide Type Slide · Exercise # 2: Implement a class Portfolio. This class has two objects, checking…
A: Required:
Q: Make a class "Shape" that stores two values: the name of a shape and its area. Initially the name of…
A: A class is the basic building block of object oriented modelling. It contains data and operations on…
Q: Class: Square Create a class called "Square", which is inherited from “TwoDimensionShape”…
A: public abstract class TwoDimensionalShape { //creating abstract method which should be override by…
Q: Make a class "shape" that stores two values: the name of a shape and its area. Initially the name of…
A: Program approach:- Create a class Shape. Constructor that assigns the string to the variable name.…
Q: s that will extend the given Animal class and optionally implement a leg count interface. (Image…
A: Given : Animal.java abstract class Animal { String FUR="fur"; String FEATHER = "feather"; String…
Q: All or Nothing Implement a public class named All that provides a single static method name…
A: We need to create an All class in java language and a static method orNothing. This method received…
Q: using c++ oop !!! kindly need help asap. Implement the shape, rectangle, and square classes with…
A: The question is to write c++ code for the given problem.
Q: Create a class namely Circle and do the following: (i) Circle will have the following member…
A: The program is written in java
Q: Your task is to create a Circle constructor that creates a circle with a radius provided by an…
A: Algorithm - Design a method with one argument as a string. Now use the below logic to solve the…
Q: Write a PaypalAccount class to include both balance and accountID as the instance variables. Make…
A: Java is a programming language was originally developed by James Gosling at Sun Microsystems.
Q: ate a class Rectangle with parameters length, breadth, and color. Use appropriate data types and…
A: public class TestRectangle { public static void main(String[] args) { Rectangle r1=new…
Q: 2019 AP® COMPUTER SCIENCE A FREE-RESPONSE QUESTIONS 2. This question involves the implementation of…
A: Note: As you have not mentioned any programming language, the program is written in JAVA language.…
Q: Write a Rectangle class. A Rectangle has properties of width and length. You construct a Rectangle…
A: Given: A class, Rectangle is designed with two constructors for initializing double data members…
Q: Write a class called Rectangle that implements the Comparable The class should contain three fields:…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Write an interface as follows: The interface is named ServiceReminder It has one method named…
A: By default interface contains abstract methods. This means that the body of method is not provided…
Q: Preliminaries • Write a Point class with two properties: 1, y. Write required constructor, get &…
A: Please give positive ratings for my efforts. Thanks. PROGRAM class Point { int x,y; public…
Q: Write a Rectangle class that has the following fields: Length (L): a double Width (W): a double The…
A: Since the language was not mentioned , the answer is provided in C++ language. Code: #include…
Q: Create a class Square derived from DrawableShape, as described in the previous exercise. A Square…
A: For classes and methods, the abstract keyword is a non-access modifier: A restricted class that…
Q: Create a rectangle class that can compute the area and the sum of its sides. Create a specialized…
A: Given: To create a rectangle class that can compute the area and the sum of its sides. Create a…
Q: Write a Circle class that has the following field: radius: a double The class should have the…
A: import java.util.Scanner; public class Demo { public static void main(String[] args) { Scanner…
Q: Need help on this. Must be in java. Make the code unique and no plagerism. Implement a Java class…
A: A class named Square is implemented which has one of its coordinates and the side of it as the…
Q: Preliminaries • Write a Point class with two properties: 1, y. Write required constructor, get &…
A: EXPLANATION: - The Point class comprises two instance variables of type double. The parameterized…
Q: Write the Circle class:• A Circle has a radius– Add instance variable– 2 constructors – one should…
A: Create a class Circle and define it's instance variable as private type and just declare default…
Q: Write a Rectangle class that has the following fields: Length (L): a double Width (W): a double The…
A: * Writting program in c++ as no programming language in mentioned in the question. #include…
Q: Create a rectangle class that can compute the area and the sum of its sides. Create a specialized…
A: import java.util.Scanner; public class Rectangle { //class Rectangle int len,…
Q: Write a Rectangle class. Its constructor should accept length and width as a parameter. It should…
A: Answer has been explained below:-
Q: Text Class The Text class inherits from Drawable and it will be used to display the player's score.…
A: It is defined as an interpreted, object-oriented, high-level programming language with dynamic…
Q: Create a Metal class that has at least one weight property. Write proper constructor and other…
A: Java code for above scenario :- class Metal{ public int wt; public Metal(int weight){…
Q: class Point with instance variables as: xCoordinate(int) and yCoordinate(int). Write public instance…
A: Program code: Filename: Point class(PointClass.java) class PointClass{ private int xCoordinate;…
Q: (The HyPoint class) Design a class named MyPoint to represent a point with x- and y-coordinates. The…
A: Answer
Q: This composition example contains classes Date, Employee and EmployeeTest .Class Date declares…
A: public class EmployeeTest { public static void main(String[] args) throws Exception { //create…
Q: Check this code and execute the rectangle class with some modifications: - change to other shapes…
A: Task : Modify rectangle class to show the output of another shape. Add attribute color to the…
Q: Write a class called Dog that contains instance data that represents the dog's (string literal) name…
A: main.java (code) public class Main { public static void main(String[] args) { // Creating…
Q: 1A. Create a Die class with one integer instance variable called sideUp. Give it a constructor and a…
A: Note: Programming language is missing in the question. So we will answer this program in Java…
Q: Implement the above system using inheritance in the best possible way. Keep every object size as…
A: The given system of classes for inheritance are implemented as follows: Class Region acts is…
Q: Design a new Triangle class that extends the abstract GeometricObject class: • Draw the UML diagram…
A: Creating a abstract GeometricObject class defines the abstract functions in that. And extends the…
Q: Create a class Rectangle with parameters length, breadth, and color. Use appropriate data types and…
A: Using C++ Language here
Q: Implement a class Triangle. A Triangle is defined by the x- and y- coordinates of its three corner…
A: Assume a triangle with three points (x1,y1), (x2y2) and (x3, y3) as shown below There are three…
Q: Extend the ItemToPurchase class per the following specifications: Private fields string…
A: import java.util.*;import java.lang.*;import java.io.*; class Item{ private String itemName;…
Q: Define an abstract class Shape with abstract method CalculateSurface() and fields width and height.…
A: class program { static void main(string[] args) { Shape[] shapes = new Shape[6]; shapes[0] = new…
Q: what is needed to be solved: Execute the rectangle class with some modifications: - add color…
A: Answer: Main.cpp: #include <iostream>#include "Rectangle.h"#include "Triangle.h" using…
Q: Design and implement a Java class named Book with two data members: title and price. The class…
A: Class Book contains basic details about book and getter/setter method. Class BookShelf contains an…
Step by step
Solved in 2 steps with 1 images
- Design a new Triangle class that extends the abstract GeometricObject class: Draw the UML diagram for the classes Triangle and GeometricObject Implement the Triangle class Write a test program that prompts the user to enter three sides of the triangle, a color, and a Boolean value to indicate whether the triangle is filled: The program should create a Triangle object with these sides and set the color and filled properties using the input The program should display the area, perimeter, color, and true or false to indicate whether it is filled or notpublic class date { private int day; // from 1 to 31 private int month; // from 1 to 12 private int year; // from 2000 upwards public void advance (); // move to next day }; Implement a constructor that initializes new objects of date class to be set to the 1st of January 2000. Implement setters for day, month, and year. Implement the advance method, which moves to the next day, ensuring that all data members are updated appropriately.Shape -width: double -length: double +allmutatorMethods Shapes2D Shapes3D -height:double *calSize():double +calVolume():double 1. Define class Shape, 2DShape and 3DShape as per UML class diagram given. 2. Define all mutator methods(set and get) for all classes. 3. Define methods calArea() with formula area - width * length for 2DShapes. 4. Define methods calArea() with formula calvolume, volume = width*length*height for 3DShapes. In the main program, declare and set data in 1 object of 3DShapes. Create an array OR ArrayList of 2DShapes, set and display the info of all objects as shown in the output. 5.
- Java Program The assignment requires two classes. Put all classes in the same package. Class Employee Attributes (all private): id: String lastName: String firstName: String salary: int Methods: Parameterized constructor for initializing a new Employee instance Getters for all attributes toString method to display an Employee's attributes (See output of executable below) Executable Class Create an array of at least eight Employee objects. Be sure to use many with identical last names, but don't order them by name in the array. Create an ArrayList from the array. Sort the ArrayList first by last name and then by first name. Using the forEach method and a lambda expression, print all employees alphabetically sorted by name. Create a LinkedList from the ArrayList. Create an iterator capable of cycling both forward and backward through the LinkedList. Iterate forward through the LinkedList without generating any output. Then iterate backwards through the LinkedList to print…Code the StudentAccount class according to the class diagramMethods explanation:pay(double): doubleThis method is called when a student pays an amount towards outstanding fees. The balance isreduced by the amount received. The updated balance is returned by the method.addFees(double): doubleThis method is called to increase the balance by the amount received as a parameter. The updatedbalance is returned by the method.refund(): voidThis method is called when any monies owned to the student is paid out. This method can onlyrefund a student if the balance is negative. It displays the amount to be refunded and set thebalance to zero. (Use Math.abs(double) in your output message). If there is no refund, display anappropriate message.Test your StudentAccount class by creating objects and calling the methods addFees(), pay() andrefund(). Use toString() to display the object’s data after each method calledpublic class StairViewer public static void main(String(] args) // Step 2: Create a rectangle and draw it as the // top step of the stair // location: (20, 10) // size: (20, 20) 18 // Step 3: Create a rectangle and draw it as the 19 // middle step of the stair 20 // location: below the top step, aligned on left // size: (40, 20) 21 22 23 24 // Step 4: Create a rectangle and draw it as the 25 // bottom step of the stair 26 // location: below the middle step, aligned on left // size: (60, 20) 27 28 29 30 } 31 32
- Design a class Parallelogram that contains two private data members: - double length, - double height. Parallelogram class should also have following public methods: - parameterized constructor, - a method to calculate area of parallelogram. Design another class Rectangle that inherits from Parallelogram (since a Rectangle is-a Parallelogram). Class Rectangle should have the following public members: - parameterized constructor, - a method to calculate perimeter, - a method to tell if the Rectangle object is a Square. Develop the main function to fully test these two classes. Note: 1. please use multiple files (separate compilation) 2. length and height should be protected members in the base class, as you need them to calculate perimeter of a rectangle.For the following four classes, choose the correct relationship between each pair. public class Room ( private String m type; private double m area; // "Bedroom", "Dining room", etc. // in square feet public Room (String type, double area) m type type; m area = area; public class Person { private String m name; private int m age; public Person (String name, int age) m name = name; m age = age; public class LivingSSpace ( private String m address; private Room[] m rooms; private Person[] m occupants; private int m countRooms; private int m countoccupants; public LivingSpace (String address, int numRooms, int numoccupants) m address = address; new int [numRooms]; = new int [numOceupants]; m rooms %3D D occupants m countRooms = m countOccupants = 0; public void addRoom (String type, double area)Java Programming: ConWay World Conway’s game of life is a simple simulation of life forms in a two dimensional grid. The ConwayCell implements the standard behavior of a call in Conway’s Game of Life. You only need to implement and test two new classes. You will create two different cells, derived from AbstractCell. 1. Alternating Cell The first class that you should create is a class named AlternatingCell. This is a cell that should alternate between being alive and dead with each generation. Add one or more of your AlternatingCells to your ConwayWorld. You can see how to add a cell in line 15 - 20 of Main.java. Give your AlternatingCell a unique display character when it is alive so that you can see it in your conway world. 2. Your own cell For the second cell you should feel free to implement any behavior that you want. If you are having trouble thinking of ideas then post up a question. You can add your custom cell in just a few places in the world, or you might choose to replace…
- This is a subclass and doesn't has a main method yet. class Vector{Object items[];int length;int size; void Grow(){// Duplicate sizesize = size * 2; // Allocate new itemsObject new_items[] = new Object[size]; // Copy old itemsfor (int i = 0; i < length; i++)new_items[i] = items[i]; // Discard old itemsitems = new_items; // MessageSystem.out.println("Growing capacity to " + size + " elements");} public Vector(){size = 2;items = new Object[2];} public void Print(){// MessageSystem.out.println("Content:"); // Traversefor (int i = 0; i < length; i++)System.out.println(items[i]);} public void Insert(int index, Object item){// Check indexif (index < 0 || index > length){System.out.println("Invalid index");return;} // Grow if necessaryif (length == size)Grow(); // Shiftfor (int i = length - 1; i >= index; i--)items[i + 1] = items[i]; // Insertitems[index] = item; // One more itemlength++; // MessageSystem.out.println("Inserted " + item);} public void Add(Object…Java - Access Specifiers Create a class named Circle that has attributes radius, area, and circumference and make the attributes private. Make a public method that sets the radius and a method that prints all attributes. Ask the user input for radius. Note: Use the PI from the math functions Inputs A line containing an integer 10 Sample Output Radius: 20 Area: 1256.64 Circumference: 125.66Rainfall Type Create a RainFall class that keeps the total rainfall in an array of doubles for each of the 12 months. Methods in the programme should return the following values: • the total annual rainfall; • the average monthly rainfall • the wettest month of the year • the month with the least amount of rain Demonstrate the class in its entirety. Validation of Input: Accepting negative amounts for monthly rainfall data is not permitted.