Declare a class Rectangle with two data members length and width and two function members: 1) to set the values of length and width (this function should be defined outside the class), 2) to calculate area (this function should be defined inside class.)
Q: Define a class named Document that contains a member variable of type stringnamed text that stores…
A: Given: Define a class named Document that contains a member variable of type stringnamed text that…
Q: Q2: Complete the main programs and writing its functions, classes and find the Area for each shape:…
A: The following steps need to be taken for the given program: Create a Triangle class with a…
Q: Write the given the following Square class definition: class Square { private:…
A: class Square { private: int side; public: Square();…
Q: Declare a class named Vehicle as a base class with two data members model (string) and year (int).…
A: Introduction: In this question, we are asked to declare two classes only that are Vehicle(base…
Q: A complex number has the form a+bi , can be expressed as the ordered pair of real numbers (a,b). The…
A: Program code: //include the header files #include<iostream> using namespace std; //Create a…
Q: Q2: Complete the main programs and writing its functions, classes and find the Area for each shape:…
A: Code is given below. #include<iostream>#include <math.h> //math.h header file for PI…
Q: Declare Snake class with two private data members length and max as integers. Define constructor to…
A: #include <bits/stdc++.h>using namespace std;#define M 4#define N 4 struct Point{ int x, y;};…
Q: Write a class having two private variables and one member function which will return the area of the…
A: The asked C++ program code is coded in the next step and is explained by using comments.
Q: Create a class Shape and two additional classes (each derived from Shape) named Rectangle and…
A: I am solving this Question in C++ A class is made abstract When it is declared at least one of its…
Q: Complete the code for the derived class by filling in the blanks for A - F. *Note: The area of a…
A:
Q: Create two classes DM and DB which store the value of distances. DM stores distances in meters and…
A: Program: #include<iostream>using namespace std;class DB;class DM{int m;double cm;public:void…
Q: reate a class Employee with following data members, name, id, and salary as private data member.…
A: Given: Create a class Employee with following data members, name, id, and salary as private data…
Q: rewrite and Insert the missing part of the code below for a class to define Book. with two…
A: In C++, Destructor is member function of the class which is called automatically when the object is…
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: Create a class: Doctor, with private data members: id, name, specialization and salary with public…
A: #include <iostream>using namespace std;class Doctor{ int id, salary; string name,…
Q: Create a class Test with two private integer data members: x and y and one member function:…
A: In the C++ program, before creating a class add necessary header files such as #include…
Q: Create a class Rational for performing arithmetic with fractions. Write a driver program to test the…
A: A C++ program is as follows, File name: “Rat.h” // a Rational object holds one Fraction number, one…
Q: Create a derived class for Cone called PartialCone. Add a second radius variable with scope specific…
A: Actually, the given formula is The formula for the volume of a partial/truncated cone is: V = h *…
Q: Write a class named circle with data member radius and three member functions get radius() to set…
A: Create a class circle and declare a variable called r to store the value of radius and the data…
Q: Create a class Rational for performing arithmetic with fractions. Write a driver program to test the…
A: Rational Number: A number that can be represented in fractional form is known as a rational number.…
Q: q1)Create a class called square so that, given a dimension using constructer, the program would…
A: Step 1: Prompt and accept side of square from the user. Step 2: Declare class Square with the…
Q: Given the following class declaration (with prototypes): class Carpet { private: double…
A: class Rectangle{ double l,b; Rectangle(double x,double y){ l=x; b=y; } }…
Q: Develop a program having a base class Student with data members rollno, name and Class define a…
A: Code: #include <iostream> using namespace std; class Student{ // this is the student class…
Q: Q4) Write a class "Rectangle'" with three data members: "width", "height" and "color"; and four…
A: Algorithm: Start Define a class Rectangle with length, width and color as its members Define init()…
Q: Create a class Rational for performing arithmetic with fractions. Write a driver program to test the…
A: File name: “Rat.h” // a Rational object holds one Fraction number, one fraction #ifndef FRAC_H…
Q: Consider the following definition of a class. class displayClass { public: void print(); ...…
A: Part (a): The function prototype to overload the assignment operator (=) for the class…
Q: Develop a program having a base class Student with data members rollno, name and Class define a…
A: Student is a base class and test should be derived from Student class which is concept of…
Q: Implement the following class MyPhoneBook. You can add additional private member variables and…
A: Answer : #include <iostream>#include <string.h> using namespace std; class PhoneBook{//…
Q: Create a class: Doctor, with private data members: id, name, specialization and salary with public…
A: Sample Response: //C++ program#include <iostream>using namespace std;//Doctor class…
Q: Implement the following class MyPhoneBook. You can add additional private member variables and…
A: Actually, program is an executable software that runs on a computer.
Q: Write a class ‘Box’ which has three members height, width and depth; To set values and use these…
A: Here is Your Code public class Box{ private int height; private int width; private int…
Q: Circle and polygon from the class Shape that contain o A parameterized constructor to initialize…
A: Consider a class Shapethat containso A data member named as ShapeName of string typeo A data member…
Q: Create a class Rectangle with length and breadth as private data members and also provide the…
A: GIVEN: Create a class Rectangle with length and breadth as private data members and also provide the…
Q: Create Class Date with variables day,month,year and a function display() and another class Time with…
A: Date Class with variables day, month, year and display function Time Class with variables hour,…
Q: Create a class: Doctor, with private data members: id, name, specialization and salary with public…
A: Program Approach: Including a necessary header file Using namespace for standard input output…
Q: Problem: Create a Fraction class with two private positive integer member variables numerator and…
A: Explanation Create a class Fraction with two private numbers numerator and denominator. Define a…
Q: Define a base class shape that includes protected data members for area and volume of a shape,…
A: A pure virtual function is an abstract class function that is used to override the derived class. If…
Q: Design a class named MyPoint to represent a point with xand y-coordinates. The class contains: a.…
A: MyPoint -x: int -y:int + MyPoint() + MyPoint(int x,int y)
Q: Create a class: Doctor, with private data members: id, name, specialization and salary with public…
A: Constructor Constructor is said to be defined as one of the methods of a class, in which this method…
Q: Create a class: Doctor, with private data members: id, name, specialization and salary with public…
A: The programming methodology for the program is given by: Including header files class doctor Data…
Q: Q1. Consider the following definitions : Class house { private int code, rooms; float price ; Public…
A: Given class house class house{ private: int code, rooms; float price;…
Q: write a class having three variables and one member function which will return the area of the…
A: Program: //included header file #include<iostream> //included namespcace using namespace std;…
Q: If thirty objects of a class are defined and each one have three variables of data , three static…
A: If thirty objects of a class are defined and each one have three variables of data, three static…
Q: Q4) Write a class "Rectangle" with three data members: "width", "height" and "color"; and four…
A: Algorithm: Start Define a class rectangle with height width and color as its members In the init()…
Q: Write a cpp program: Declare a class Rectangle with two data members length and width and two…
A: To make function define outside the class, it must be declared inside class and its definition is…
Q: Create a class "company" displaying name, location .Create another class "employee" containg name,…
A: Step 1:- Program Approach:- 1.Create the class company 2.Create the parameterized constructor…
Q: Create a class: Doctor, with private data members: id, name, specialization and salary with public…
A: Given: Create a class: Doctor, with private data members: id, name, specialization and…
Q: 4b. Consider the class circleType as defined in Example 10-8 (Chapter 10). Suppose that the class…
A: 4b. Consider the class circleType as defined in Example 10-8 (Chapter 10). Suppose that the class…
Q: Start with the publication, book and tape classes. Add base class sales that holds an array of three…
A: Program: //included header file #include <iostream> #include <string> //inclduded…
Q: Consider the following four classes and a main function below: class PoofyTaii { public: PoofyTail()…
A: Code: #include <iostream>using namespace std;class PoofyTail{ public:…
Ps: see image for question.
Step by step
Solved in 2 steps with 1 images
- write a program c++ Define a class rectangle with the following data members: L,W and the following memelber functions: 1. Set_data that stores parameters values into data members. 2. Area that returns the area of the rectangle. 3. Ret_Lw that returns the length and width of the rectangle. # Let your main Function declares two objects of the length (L) and the width (W) of the rectangle of largest area.Imagine a publishing company that markets both books and audio-cassette versions of its works. Create a class publication that stores the title (a string) and price (type float) of a publication. From this class derive two classes: book with which adds a page count (type int) and tape which adds a playing time in minutes (type float). Each of these three classes should have a getData() function to get its data from the user at the keyboard and a putData() function to display its data.Question: 3 write python program ; Implement the design of the Doctor and Engineer class derived from Person class so that the following code generates the output below:class Person: def __init__(self, name, contact): self.name = name self.contact = contact def __str__(self): s = f"Name: {self.name}\nContact: {self.contact}" return s#Write your code hered = Doctor("Dr Strange", "4585632", "Neurosurgery", "DMC")d.add_patients("Dhaka Abdur Rahim", "Dhaka John Cena", "Narayanganj John Wick", "Comilla CM Punk")print("1.=========================================================")print(d)print("2.=========================================================")d.show_patient_list("Dhaka")print("3.=========================================================")d.show_patient_list("Rajshahi")print("4.=========================================================")d.add_patients("Narayanganj Naruto…
- Suppose, we have two related (child) classes named Doctor and Patient. Data membersrequired by each class are given below. data members of doctors name type remarks name string full name of doctor age int age of person spec string speialization of doctor data members of patient name type remarks name string full name of person age int age of he person diag string diagnosed problem Using the information given above, create the following three classes. a. A parent class named Person containing common data members and functionality ofthe child classes; Doctor and Patientb. The class Doctor which is publicly inherited from the class Personc. The class Patient which is publicly inherited from the class Person Each class must contain at least two constructors in addition to the appropriate set() and show() functions. Functions of child classes should call appropriate functions of the parent class to perform the common functionality. All the function…Write a JAVA program Write a function inside ProblemSolution class whose return type is void, accepts an array and the length of the array as input parameters. The function should call a static method display of MyArray class by passing an array and length value. Input 5 1 5 8 2 0 Where, First line of input represents the size of an array. Second line represents array elements. Output 1 5 8 2 0 Assume that, N is an integer within the range [0 to 10000]. Array elements are integers within the range [-2147483648 to 2147483647].Implement a class Clock whose get_hours and get_minutes member functions return the current time at your location. To get the current time, use the following code, which requires that you include the <ctime> header: time_t current_time = time(0);tm* local_time = localtime(¤t_time);int hours = local_time->tm_hour;int minutes = local_time->tm_min; Also provide a get_time member function that returns a string with the hours and minutes by calling the get_hours and get_minutes functions. Provide a derived class WorldClock whose constructor accepts a time offset. For example, if you live in California, a new WorldClock(3) should show the time in New York, three time zones ahead. Which member functions did you override? (You should not override get_time.).c++
- Build a class Pet having the following data membersa. Name (String)b. Gender (char)c. Type (String)d. Age (int)e. Weight (float)f. healthCondition (int)Imagine this class Pet represents your pet as a virtualobject. Provide constructors with arguments for name,gender, type, age and weight. Initialize healthCondition to 5(which means healthy). Provide getter for each of these but setter for only weight. Provide a function eat(String food). This function represents the action of eating thatwould increase the weight of the pet according to following rulesFood Increase In WeightRed Meat 0.14 kgChicken 0.12 kgPet Food 0.17 kgSupplement 0.1 kgFish 0.09 kgThe eat function returns the new Weight of the pet object.Provide another function fallSick() that reduces the healthCondition of the pet 1 but it cannot gobelow 0. Provide a function bool isDead() this function returns true if the healthCondition of a pet is 0and false otherwise. Add another function recover(). This function increases…Write a python program that takes input values as integer, checks the number is not less than 10 (otherwise take input again) and prints the previous 10 numbers i.e. 10, 9, 8, … Concatenate the integer and string values and print as a string Write a python code to create a class named as ‘Employee’ with attributes i.e. ID, Name, Designation, Qualification, Salary, Taken-Leaves, Allowed-Leaves and the functions applyLeave(). This function will take number of leaves as an input and check Allowed-Leaves to see whether the employee can take leaves or not. If he can take, deduct these leaves from Allowed-Leaves and add in Taken-Leaves. Otherwise show message ‘you cannot take leave’. Create another class ‘Intern’ and inherit ‘Employee’ as super class.Computer Science In Java, create a class Die representing a die to roll randomly. -Give Die a public final static int FACES, representing how many faces all dice will have for this run of the program. -In a static block, choose a value for FACES that is randomly chosen from the options 4, 6, 8, 10, 12, and 20. -Give Die an instance variable current, representing the last value it rolled. (cannot be less than 1 or more than FACES) -Give Die int instance variables maxCount and minCount. (cannot be negative) -Give Die a method roll that randomly sets current to a value between 1 and FACES. If the die rolls a 1, increase minCount, if the die rolls FACES, increase maxCount. -Give Die a static method sumDice, which takes a variable length parameter list of Dies and returns the sum of all their current values. -Give Die a static method sameDice, which takes a variable length parameter list of Dies, and returns true only if all of them have the same current value. Do not compare…
- Write a program in C++ using OOP, to create a class (student), that contain a private data (name, five grads). then create the following function: 1) (set_info()) to read the private data 2) (Print_info()) to Print student name and grades. 3) (Grade E()) as a friend function that calculate the grades average and print the student evaluation according to the following conditions: FAIL when (av=60 and av=70 and av 80 and av=90)In this task, we’re going to be simulating an email message. ●Create a class definition for an Email.The initialiser takes in two arguments and stores them as instance-level variables:○from_address - the sender’s email address.○subject_line - the subject of the email.○email_contents-the content of the email.●In addition,the initialiser will create two more instance-level variables with defaultvalues:○has_been_read - initialised to False.○is_spam - initialised to False.●Create a function in this class called mark_as_read which should change has_been_read to true.●Create a function in this class called mark_as_spam which should change is_spam to true.●Create another class called "Inbox" to store all emails (note that you can have a list of objects). The initaliser doesn’t take any arguments, and only initialises an empty list. This list is where all of your Email objects will be stored.●Within the Inbox class, create the following methods:○add_email (self, from_address, subject_line,…Consider the following class and answer questions after this class #include <string> using namespace std; class Account { public: Account(string accountName, int initialBalance) { name=accountName; if (initialBalance > 0) { balance = initialBalance; } } void deposit(int depositAmount) { if (depositAmount > 0) { balance = balance + depositAmount; } } int getBalance() const { return balance; } void setName(string accountName) { name = accountName; } string getName() const { return name; } private: string name; int balance; }; a) Rewrite the above class. Write prototype of all functions inside class and definition outside. b) Write two friend functions to change the value of name and balance. c) Write a print function and…