Write the definitions of the member functions outside of the class based on the desriptions given below: (a) set_Data() Get user inputs for isbnNo, title, author, price and discountperc. (b) calcDiscountedPrice() Find the discountedPrice (the price after minus the discounted amount). (c) print() Display the book details. (d) getDiscountedPrice() Return the discountedPrice. (e) Books() Default constructor of the class. (f) Books(string,string,string, float,float); Parameterized constructor of the class.
Q: Refer to the UML class diagram given below: Subject a) - subjectTitle: String - creditHour: int -…
A: Solution: JAVA code: Subject.java public class Subject{ // Declaring class variables String…
Q: Create a class of Company having private data members. Make all constructors along with setter…
A: Create a class of Company having private data members. Make all constructors along with setter…
Q: Write the following program in c++. i. Create a class of your own choice with 5 attributes. ii.…
A: C++ code:
Q: Given main() and the Instrument class, define a derived class, StringInstrument, for string…
A: Defining a derived class, StringInstrument, for string instruments. StringInstrument.h #ifndef…
Q: Create three classes Person, Professor and Student. The class Person should have data members name…
A: The program uses the Scanner package which is used for taking user inputs during run time. Classes…
Q: Write a Cpp program to implement a class named microwave that contains data members as Brand, and…
A: Declare data members as private and member functions as public
Q: Create a class Student that contains information about a student’s name, semester, roll no, and date…
A: Program Explanation: 1) Implement the header file. 2) Declare the integer 3) Implement the main type…
Q: Given this class specification: Class: Car Data members: int cost Write these function definitions:…
A: When a constructor calls another constructor of the same class, then it is called the constructor…
Q: Employee is a class with a function to set the details of the employee such as the emp_id, Name,…
A: You have not mentioned programming language so I am going to write code in c++. #include…
Q: Define the class studentType with the same components as the struct studentType, and add member…
A: The class will have setters for all 6 instance variables and a member function to display the…
Q: a member function in a class can access all of its class's member variables, but not if the…
A: Option B: False
Q: Regarding above code, select the correct answer among below 4 choices. A) The code is correct. B)…
A: Class is a set of objects having common properties.It is a blueprint which is used for object…
Q: Create a class Person with private data members name, age, height and weight. The class must also…
A: #include <iostream> using namespace std; class Person{ private: string name; int age;…
Q: Write the following program in c++. i. Create a class of your own choice with 5 attributes. ii.…
A: The program is given below:-
Q: Define the struct call with the components code (of type char) and units (of type int). Design a…
A: Code: #include <iostream> #include <fstream> using namespace std;//structure call…
Q: Given the base class Instrument, define a derived class StringInstrument for string instruments.…
A: This is the complete code for the question TODO section is highlighted in the code :- class…
Q: Assuming that soap is an instance of the Inventory class, which of the following is a valid call to…
A: Lets see the solution.
Q: hapter 9 defined the struct studentType to implement the basic properties of a student. Define the…
A: Terms used in the above question: struct(structure):- In C++, a structure is a type that the user…
Q: True/False: a member function in a class can access all of its class's member variables, but not if…
A: Please find the answer below :
Q: Write a class Teacher that contains the attribute teacher name, age and address. It also contains…
A: Actually, c++ is a powerful general purpose language. It is a high level language.
Q: Using c++ create a class with a static member item so that when ever a new object is created the…
A: Static: If no other initialization is present, a static member is shared by all objects of the…
Q: Writing the setbank functions Setbalance Setaccont In order to enter the creditcard data instead of…
A: As per the requirement program is modified. Note: Newly added code is highlighted in bold. And both…
Q: Create a class Employee with the following attributes and member functions: ● Employee registeration…
A: #include<iostream>using namespace std; class emp {public: int eno; float bp, hra,…
Q: USE TEMPLATE PROVIDED AT END OF QUESTION WHILE MAKING SOLUTION -----------------------------------…
A: Here I have first of all completed the method generateBill() in the bill.cpp to display the bill…
Q: True/False: to derive class A from class B, A must have a private member function. A) True B)…
A: Inheritance: Inheritance allows creation of new classes from existing classes. The new classes that…
Q: Write the definitions of the member functions of the class calendarType (designed in Programming…
A: GIVEN: Write the definitions of the member functions of the class calendarType (designed in…
Q: Write a class Medical Staff that contains an attribute ID to store staff’s identity. The class…
A: Note: since your question contain multiple question but we can answer only one question at a time…
Q: Write a class named student with attributes name of student and marks obtained by student. Class has…
A: As the program language was not mentioned so implementing the question using C++. Program:-…
Q: • Function cancelReservation • Parameters: · An object of type HikeList • An object of type…
A: Answer
Q: Q1: Implement a Place class as specified: data members: name - name of the Place (dynamic variable)…
A: As per guidelines we can answer only one question for answer of other questions ask separately
Q: What's the difference between a class's static and non-static data members? Give an example of why a…
A: Here is the answer :
Q: Question 8 Write a class called myclass. This class has two data members, a and b. The values of…
A: class myclass: def __init__(self, a, b): self.a = a self.b = b def get_a(self):…
Q: Q.5 Write a class car and implement the following attributes. Then write the main function and take…
A: Find the code attached.
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: Person Class: Person class has attributes: String name, address and int age. Write setperson()…
A: Inheritance is a concept in which one class acquires the properties of another class. An inheriting…
Q: Consider a class Computer having Two fields (i.e. companyName, price) and A single function named…
A: Define a class. Use its constructor. Define a function for dynamic binding. Define another class…
Q: Construct function definitions for all public member functions where setWeight () is to set the…
A: The program is written in the C++ programming language. Please find the source code in step 2.
Q: C++ Given the following partially complete class Cellphone, write two member functions associated…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: Given main(), complete the Calculator class (in files Calculator.h and Calculator.cpp) that emulates…
A: Program Explanation: Include the required header files Define a class for calculator Define the…
Q: A. Write the code of the class for the following UML diagram. Person -name: String -age: int +Person…
A: //class Personclass Person{ //declare variables String name; int age; public //parameterised…
Q: What is the difference between a class's static data member and a non-static data member? Give an…
A: Introduction: The following is the distinction between a class's static data member and a class's…
Q: Person Class: Person class has attributes: String name, address and int age. Write setperson()…
A: GIVEN: Create a java program for the above question.
Q: Define a struct to represent a product item with the fields: name, ID, price. 2) Define two named…
A: #include <stdio.h> #include <string.h> int main() { struct ProductItem{ char *name;…
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: Given main() and the Instrument class, define a derived class, StringInstrument, for string…
A: From the given information in main(), StringInstrument class contains following members: Data…
Q: A client changing the values of private data members is: lect one: O a. Possible using public…
A: Answer:- b. Possible using public functions and references.
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: Please write the Java program for the given scenario Create a class Film with string objects which…
A: Program Approach: Create class named Film and create variables and constructors. Create reference…
Q: Create three classes Person, Professor and Student. The class Person should have data members name…
A: Since no programming language is mentioned, I am using python. Algorithm: Start Create a class…
Write a C++ program.
Step by step
Solved in 3 steps with 2 images
- // volunteer.h #include class Volunteer { public: Volunteer () { } std::string Name () void SetName (const private: std::string name_; }; const { return name_; } std::string& name) { name_ = name; }C# languageCreate a class for “Plane” having functionalities (methods) startengine(), fly() and land(). When ever engine starts it should reset the attribute TTK (Total travel kilometer) to zero and attribute Fuel to 100. On fly() it should add 10 kilometers if the Fuel attribute is greater than zero and decrement Fuel by 20.On land() it should print total distance covered. Write the code providing all necessary details. And then show working object of Plane in main().Programming Language= PYTHON 1. Pet Class Write a class named Pet, which should have the following data attributes: • _ _name (for the name of a pet) • _ _animal_type (for the type of animal that a pet is. Example values are ‘Dog’, ‘Cat’, and ‘Bird’) • _ _age (for the pet’s age) The Pet class should have an _ _init_ _ method that creates these attributes. It should also have the following methods: • set_name This method assigns a value to the _ _name field. • set_animal_type This method assigns a value to the _ _animal_type field. • set_age This method assigns a value to the _ _age field. • get_name This method returns the value of the _ _ name field. • get_animal_type This method returns the value of the _ _animal_type field. • get_age This method returns the value of the _ _age field. Once you have written the class, write a program that creates an object of the class and prompts the user to enter the name, type, and age of his or her pet. This data should be stored as the object’s…
- True or false ? Assuming class Quiz { public: void TakeIt ( ); }; Quiz cs2b_quiz; Quiz * p_quiz = & cs2b_quiz; The syntax to invoke TakeIt ( ) member function using the pointer is: p_quiz->TakeIt ( );Programming Language= PYTHON 1. Pet Class Write a class named Pet, which should have the following data attributes: • _ _name (for the name of a pet) • _ _animal_type (for the type of animal that a pet is. Example values are ‘Dog’, ‘Cat’, and ‘Bird’) • _ _age (for the pet’s age) The Pet class should have an _ _init_ _ method that creates these attributes. It should also have the following methods: • set_name This method assigns a value to the _ _name field. • set_animal_type This method assigns a value to the _ _animal_type field. • set_age This method assigns a value to the _ _age field. • get_name This method returns the value of the _ _ name field. • get_animal_type This method returns the value of the _ _animal_type field. • get_age This method returns the value of the _ _age field. Once you have written the class, write a program that creates an object of the class and prompts the user to enter the name, type, and age of his or her pet. This data should be stored as the object’s…C# Encapsulation Example Following is the example of defining an encapsulated class in c# programming language. using System; using System.Text; namespace Tutlane { class User { private string location; private string name; public string Location { get { return location; } set { location = value; } } public string Name { get { return name; } set { name = value; } } } class Program { static void Main(string[] args) { User u = new User(); // set accessor will invoke u.Name = "Suresh Dasari"; // set accessor will invoke u.Location = "Hyderabad"; // get accessor will invoke Console.WriteLine("Name: " + u.Name); // get accessor will invoke Console.WriteLine("Location: " + u.Location); Console.WriteLine("\nPress Enter Key to Exit.."); Console.ReadLine(); } } } As you can see from the example above, we used properties to specify the fields in the enclosed class, and we can change the values of the fields by using the get and set accessors of properties. 1. Can you…
- Employee class Write a Python program employee.py that computes the cumulative salary of employees based on the length of their contract and their annual merit rate. Your program must include a class Employee with the following requirements: Class attributes: name: the name of the employee position: the position of the employee start_salary: the starting salary of the employee annual_rate: the annual merit rate on the salary contract_years: the number of years of salary Class method: get_cumulative_salary(): calculates and returns the cumulative salary of an employee based on the number of contract years. Round the cumulative salary to two digits after the decimal point. Example: If start_salary = 100000, annual_rate = 5% and contract_years = 3: Then the cumulative salary should be : 100000 + 105000 + 110250 = 315250 Outside of the class Employee, the program should have two functions: Function name Function description Function input(s) Function output(s) / return…C++ Define and implement a class named Movie with the following members: std::string name; float cost; bool signedByDirector; Movie(); Movie(std::string movietitle); std::string getName (); float getCost(); void setCost (float newCost); // Price is modified by signing (see description) // Change cost to newCost // Returns signedByDirector bool issigned (); void signMovie(); Ensure each variable and function has been set an appropriate access modifier and your header file includes a header guard. Your methodgetCost() should return cost, but if the Movie is signed, it should return the cost plus a markup of 20%. For example, if a movie was worth $100, getCost () should return 100. If the same movie was signed by the author, then getCost() should return 120. Note: This function should not modify the class member cost, instead it should use cost and signedByDirector to determine the actual cost/value of the Movie. Your default constructor should set the cost to 0, the title to "NO TITLE".…Problem: Employee and ProductionWorker Classes Write a python class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: • Shift number (an integer, such as 1, 2, or 3)• Hourly pay rateThe workday is divided into two shifts: day and night. The shift attribute will hold an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2. Write the appropriate accessor and mutator methods for this class. Once you have written the class, write a program that creates an object of the ProductionWorker class, and prompts the user to enter data for each of the object’s data attributes. Store the data in the object, then use the object’s accessor methods to retrieve it and display it on the screen Note: The program should be written in python. Sample Input/Output: Enter the name: Ahmed Al-AliEnter the ID number: 12345Enter the department:…
- #include #include #include #include using namespace std; class AttackInfo{ public: }; int dmg; string description; AttackInfo() AttackInfo(int a, string b){ dmg = a; description = b; class BaseCharacter{ private: } string name; int maxHP,presentHP,dodgeChance; public: int strength, agility,intelligence, baseDamage; public: BaseCharacter() { BaseCharacter(string a, int b, int c, int d, int e, int f, int g){ name = a; strength = b; agility = c; intelligence = d; maxHP = e; presentHP = maxHP; dodgeChance = f; baseDamage=g; } AttackInfo primaryAttack(){ return AttackInfo(baseDamage,"strikes at"); } at"); AttackInfo secondaryAttack(){ return AttackInfo(baseDamage,""); } } void takeDamage(int a){} string toString(){ return "Name: "+getName()+"Max HP: "+to_string(getMaxHp())+" Present HP: "+to_string(getPresentHP())+"Dodge Chance: "+to_string(get DodgeChance()); } }; AttackInfo getAttack(){ return primaryAttack(); }; class Warrior: public BaseCharacter{ private: string getName(){return name;}…LOVELY PROFESSIONAL UNIVERSITY Academic Task No. 1 School : of Computer Science and Engineering Name of the faculty member_Ms. Gauri Mathur_ Course Code: CSE202 Faculty of: Technology and Sciences Course Title: Object Oriented Programming Program: Max. Marks: 30 Term: Is Rubric Applicable: No Date of Allotment: 26/02/2021 Date of Submission: 09/03/2021 Important Guidelines: 1. All questions in this Academic Task are compulsory. 2. It is mandatory to attempt all questions of the assignment in your own handwriting on A4 size sheets/pages with a blue colour ink pen. Any other mode of attempt (typed or printed codes or table) except hand written/drawn will not be accepted/considered as valid submission(s) under any circumstances. 3. Every attempted sheet/page should carry clear details of student such as Name, Registration number, Roll number, Question number and Page number. The page numbers should be written clearly on the bottom of every attempted sheet in a prescribed format as: for…8- Create an instance of the following class and call its methods. class Exam{ int grade; public: void seta (int b) (grade=b; } int geta () {return grade; } 9- When the word const is put before the variable definition, what does that mean? 10- How to concatenate two strings in C++ language? C++