In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the length = x; width = y; void print() const; //Output length and width double area(); //Calculate and return the area of the rectangle (length*width) double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private: double length; double width; }; Set the length of the rectangle to 24 and the width to 30.
Q: in java create a class shopping mall. It has Items with name, manufacturer and price. Provide…
A: public class Tester{ public static void main(String[] args) { //create instances of items Item…
Q: Computer Science In Java, create a class Die representing a die to roll randomly. -Give Die a…
A: ans is given below
Q: UML Diagrams Shape (interface) + getPerimeter() : double + getArea(): double + getDetails() : void…
A: Triangle.java: public class Triangle { int sideA,sideB,sideC; public Triangle(int sideA, int sideB,…
Q: Java --- Please help me understand further the code below. Thank you!| --- Circle.java public class…
A: ALGORITHM: Step 1: Create an interface Shape Step 2: In that create 4 classes circle, rectangle,…
Q: Java program requirements: - a PesoCurrency class with an amount attribute. - Define an overloaded…
A: JAVA Program to create PesoCurrency with an amount attribute and a method to convert pesos to dollar…
Q: public class BClass { private int x; public void set(int a) { x = a; } public void print( {…
A: print() method displays the respective data member of the class. In method overriding, we need to…
Q: COMPILER ERROR MESSAGES Driver.java:4: error: class TriangleDriver is public, should be declared in…
A: - We need to highlight and correct the problem described in the picture above.
Q: Given the following code, the output is class Base { private int x = 5; } class Derived extends Base…
A: This is an example of inheritence.
Q: Java programming language I need the two classes ( the testing class and the class with the…
A: We can merge both the classes in one (testing and method class) . We can use main method the…
Q: java programming There are three System.out.println() calls in the following code. Find the output…
A: There are three System.out.println() calls in the following code are as follows:
Q: Java 2 billBook -invoiceNumber: String -visitDate: String -patientName: String -paid: boolean…
A: Program structure: Class bill is created. Parameters are defined. printinvoice() method is created.…
Q: CODE IN JAVA 2. Exploring Variable Length Parameter Lists The file Parameters.java contains a…
A: Answer is given below-
Q: In java language Write a Rectangle class. A Rectangle has properties of width and length. You…
A: File name: "Rectangle.java" public class Rectangle { private double length; private…
Q: problem description and answer all the questions about it: Problem Description: In the following…
A: Objective: This program modifies the given code and displays the bill using the factory design…
Q: void mysteryFunction(int myList[][5], int r, int c) { int i, j, k, curr, temp; for( (1) ) for (i =…
A: Q: Code the given problem
Q: Write Program Java language Create an Animal class and an arraylist from that class you created.…
A: The code for Animal class is written below: class Animal{ // creating Animal class int…
Q: 1)The program should be written in JAVA. Create a "Car" class that keeps car ids and prices. And…
A: The given problem is to be solved using JAVA programming language where the requirement is to have:…
Q: write a java program This composition example contains classes Date, Employee and EmployeeTest…
A: Given: Class EmployeeTest creates two Date objects to represent an Employee’s birthday and hire…
Q: this code is in java. Explore the given classes. Implement a getter method on the WasteRobot class…
A: Answer
Q: Write a method named equals that will be placed inside the Rectangle class. The equals method…
A: The required method has been provided in step two. please feel free to post follow-up questions in…
Q: In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the…
A: The problem is based on the basics of classes in C++ programming language.
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: Complete the missing line of code: public class Rectangle { private int width; private int height;…
A: The problem is based on parameterised constructors in C++ language.
Q: JAVA WRITE THE OUTPUT OF THE PROGRAM AND WRITE THE UML DIAGRAM OF THESE PROGRAM : A.) public class…
A: In the given program code, we define a class Invoice with private members integer type item_number,…
Q: class A{ protected: int x, y; public: int z; }; class B: private A{ private: int a, b, c; public:
A: a) B have 6 data members. They are x,y,z,a,b,c b) No data members are visible in B. c) x,y,z,a,b,c…
Q: Double any element's value that is less than controlValue. Ex: If controlValue = 10, then dataPoints…
A: Program: import java.util.Scanner; public class StudentScores { public static void main (String…
Q: Imagine a publishing company that markets both book and audiocassette versions of its work. Create a…
A: Actually, program is a executable software that runs on a computer.
Q: USING C++ Implement the Rectangle class below: *******RECTANGLE CLASS******* class Rectangle {…
A: #include <iostream>using namespace std;class Rectangle{ private: double width; double…
Q: 4. Implement the following class diagram. Shape #color:String +Shope (color:String ) +getColor…
A: For implementing the given diagram as classes follow the below algorithm: Create class Shape:…
Q: write a c++ program Write a class Date that represents a date consisting of a year, month, and day.…
A: #include<iostream> #include <string> using namespace std; class Date { public: Date(…
Q: public class JavaApplication7 { public static void main(String [] args) { //TODO - write your own…
A: public class Main{ public static void main(String[] args) { //testing method…
Q: Write an application that displays the strings in the provided array alphabetically in ascending…
A: Java: import java.util.*;public class Main{ public static void main(String[] args) {…
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: Python language Write a initializer method for the class Test. It has 2 parameters/field…
A: __init__ method in python is called as as initializer method in python. steps to declare…
Q: public class Ex1 { public static void main( String args[] ){ int array[] = { 1, 2, 3, 4, 5 };
A: Code:
Q: Design a class Parallelogram that contains two private data members: - double length, - double…
A: // C++ program to demonstrate implementation // of Inheritance #include <bits/stdc++.h> using…
Q: c) Draw a UML Diagram for the following source code. (CLO1, CLO2) public class MyCircle { double…
A: Answer: UML diagram for given java program:
Q: Write a Rectangle class. A Rectangle has properties of width and length. You construct a Rectangle…
A: Introduction of the Program: The Java Program uses default and parameterized constructor to…
Q: IN RUBY Write a function that returns the distance the snail must travel to the top of the tower…
A: 1) Below ia Ruby program that write a function total_distance snail must travel to the top of tower…
Q: ake screenshots Write a Java program to show how to widen a smaller size type to a larger size type
A: Converting a smaller type to a larger type size (automatically) is known as Widening Casting. byte…
Q: A Truck can be described as having a make (string), model (string), gas tank capacity (double), and…
A: Solution: Given, Truck.java class Truck{ private String make, model; private double…
Q: Python Code please
A: class ItemToPurchase(): def __init__(self, item_name = 'none', item_price = 0, item_quantity = 0,…
Q: public class A extends C { public void method1() { System.out.print("a1 "); } public String…
A: The above program is a program of inheritance in java. Inheritance is an object-oriented programming…
Q: Update Bresenham’s line (JAVA) method
A: Step1: Start Algorithm Step2: Declare variable x1,x2,y1,y2,d,i1,i2,dx,dy Step3: Enter value of…
Q: Explain the following Java Polymorphism code in details. class Shape { public double getArea() {…
A: Lets see the solution.
Q: JAVA Create a class called Quadratic for representing a one-variable quadratic expression of the…
A: A quadratic equation is in the form of the a×x2+b×x+c=0 Where a,b, and c are the coefficients of the…
Q: In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the…
A: - The question wants us to code for the area finding problem in C++.
In C++
class rectangleType
{
public:
void setLengthWidth(double x, double y); //Sets the length = x; width = y;
void print() const; //Output length and width
double area(); //Calculate and return the area of the rectangle (length*width)
double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle)
private:
double length;
double width;
};
Set the length of the rectangle to 24 and the width to 30.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the length = x; width = y; void print() const; //Output length and width double area(); //Calculate and return the area of the rectangle (length*width) double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private: double length; double width; }; Print out the area of the rectangle.Explain the following Java Polymorphism code in details.class Shape{public double getArea(){return 0.0;}}class Circle extends Shape{private int x,y;private double radius;public Circle(){x = y = 0;radius = 0.0;}public Circle(int x, int y, double radius){this.x=x;this.y=y;this.radius = radius;}public void drawShape(){System.out.println("Circle.drawShape()");}public double getArea(){double area = Math.PI* radius * radius;System.out.println("Circle area="+area);return area;}}class Rectangle extends Shape{private int x,y,h,w;public Rectangle(){x = y = h = w = 0;}public Rectangle(int x, int y, int h, int w){this.x=x;this.y=y;this.h=h;this.w=w;}public void drawShape(){System.out.println("Rectangle.drawShape()");}public double getArea(){double area = w * h;System.out.println("Rectangle area="+area);return area;}}public class ShapeTest{public static void main(String[] args) {Shape s = new Shape();Circle c = new Circle(0,0,10.0);Rectangle r = new Rectangle(0,0,5,4);System.out.println("Return…In C++ QUESTION 14 class rectangleType { public: void setLengthWidth(double x, double y); //Sets the length = x; width = y; void print() const; //Output length and width double area(); //Calculate and return the area of the rectangle (length*width) double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private: double length; double width; }; Write the function definition for the function perimeter
- USING C++ Implement the Rectangle class below: *******RECTANGLE CLASS******* class Rectangle { private: double width; double length; public: void setWidth(double); void setLength(double); double getWidth() const; double getLength() const; double getArea() const; }; *******END OF RECTANGLE CLASS******* Enhance the Rectangle class with two new member functions: double getPerimeter() - returns the perimeter of the rectangle, i.e. 2*width+2*length bool isSquare() - returns true if the rectangle is a square, i.e. length is equal to width, returns false if not Demonstrate your class works with the main function that instantiates a Rectangle object and shows sample output for these functions workingJava - Encapsulation A rectangle can be formed given two points, the top left point and the bottom right point. Assuming that the top left corner of the console is point (0, 0), the bottom right corner of the console is point (MAX, MAX) and given two points (all “x” and “y” coordinates are positive), you should be able to draw the rectangle in the correct location, determine if it is a square or a rectangle, and compute for its area, perimeter and center point. To be able to do this, you should create a class Point (that has an x-coordinate and a y-coordinate). Also, create another class called Rectangle. The Rectangle should have 2 points, the top left and the bottom right. You should also implement the following methods for the Rectangle: display() - draws the rectangle on the console based on the samplearea() - computes and returns the area of a given rectangleperimeter() - computes and returns the perimeter of a given rectanglecenterPoint() - computes and returns the center point…JAVACreate a class called Quadratic for representing a one-variable quadratic expression of the form: ax2 + bx + c a,b and c here are the coefficients. The class should contain the following methods: * A constructor that accepts values for a, b, and c. * public double getA() * public double getB() * public double getC() * public double evaluate (int x) * will return the value of the expression at point x * public double discriminant() - that will return (b2 - 4ac) * public boolean isImaginaryRoots() - roots are imaginary if (b2 - 4ac) < 0 * public boolean isRealRoots() - roots are real if (b2 - 4ac) >= 0 // these methods can only be invoked if the roots are not imaginary * public float firstRoot() * public float secondRoot() * public boolean isPerfectSquare(); // If the first and second roots are equal * Try to override the toString methods * Write a sample main program that will work as shown below. Example output: coefficient a: 4 coefficient b: 4 coefficient c: 1…
- Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A,B,C,D,E" is correct. Each question has one correct answer. Thank you. Part 1 - 3. Given the following code, the output is __. class Base { private int x = 5; }class Derived extends Base { x = 6; }public class Sample { public static void main(String[] args) { int x = 7; Derived d1 = new Derived(); System.out.print(d1.x); }} A. 0B. 5C. 6D. 7E. Error message Part 2 - 4. A class Animal has a subclass Mammal. Which of the following is true? A. class Animal extends Mammal { }B. class Mammal extends Animal { }C. class Animal implements Mammal { }D. class Mammal implements Animal { }E. class Mammal { Animal a1 = new Animal(); }In java language Write a Rectangle class. A Rectangle has properties of width and length. You construct a Rectangle object by providing the width and length in that order. If no width and length are provided to the constructor, construct a Rectangle with width 0.0 and length 0.0. We want to be able to get and set both the width and the length independently. We also want to be able to ask for the area of the rectangle and the perimeter of the rectangle. What will the object need to remember? width and length - those are the instance variables. Rectangle class has these constructors : public Rectangle() - Constructs a new rectangle with width and length of 0.0. public Rectangle(double width, double length) - Constructs a new rectangle with the given width and length. Remember that the job of the constructor is to initialize the instance variables. It has these methods. public double getWidth() - Gets the width of this Rectangle public double getLength() - Gets the length of this…In java language Write a Rectangle class. A Rectangle has properties of width and length. You construct a Rectangle object by providing the width and length in that order. If no width and length are provided to the constructor, construct a Rectangle with width 0.0 and length 0.0. We want to be able to get and set both the width and the length independently. We also want to be able to ask for the area of the rectangle and the perimeter of the rectangle. What will the object need to remember? width and length - those are the instance variables. Rectangle class has these constructors : public Rectangle() - Constructs a new rectangle with width and length of 0.0. public Rectangle(double width, double length) - Constructs a new rectangle with the given width and length. Remember that the job of the constructor is to initialize the instance variables. It has these methods. public double getWidth() - Gets the width of this Rectangle public double getLength() - Gets the length of this…
- Write a Rectangle class. Its constructor should accept length and width as a parameter. It should have methods that return its length, width, perimeter, and area. (Use Java) Show a demonstration where you create two separate rectangles.THIS NEEDS TO BE DONE IN C#! NOT JAVA! NOT C++, NOT PYTHON! PLEASE WRITE THIS IN C#! Take the following class: class Pokemon { string Name; string Type; int Health; } Override the ToString method so that it it outputs the Pokemon's heath. Example: Let's say we have a Pikachu named Sparky and it had 200 health. When we called ToString, we would get the following string: Rex: Pikachu (200)in computer programming: java Create a rectangle class that can compute the area and the sum of its sides. Create a specialized method that will allow the class to compare other rectangle objects. The comparison should identify the larger rectangle according to the object’s area. You should be able to implement the class where the user provides rectangle dimensions. The program should be able to display which of the rectangle inputs is larger using the Rectangle class method that you defined. Sample output: Enter Length R1: 1 Enter Width R1: 1 Enter Length R2: 2 Enter Width R2: 2 Results: R1 Area: 1 R1 Sum: 2 R2 Area: 4 R2 Sum: 4 R2 is the bigger Rectangle! Note: All characters in boldface are user inputs.