Give a definition for a class SmartBut that is a derived class of the base classSmart given in the following. Do not bother with #include directives ornamespace details.class Smart{public:Smart( );void printAnswer( ) const;protected:int a;int b;};This class should have an additional data field, crazy, of type bool; oneadditional member function that takes no arguments and returns a value of type bool; and suitable constructors. The new function is named isCrazy. You do not need to give any implementations, just the class definition.
Q: Question 1 Suppose we have the following definitions: class Frabjous { private: char fab[20];…
A: ANSWER:-
Q: Code a non default three-parameter constructor with parameters for unit code, credit hour and offer…
A: i have provided this answer with description in step-2
Q: Suppose the class SportsCar is a derived class of a class Automobile.Suppose also that the class…
A: A class is a blueprint for constructing objects that provide initial values for state members and…
Q: Write a java program named MyLoan that uses an abstract class named FamilyInsurance and subclasses…
A: The complete code is given below with the output.
Q: 4. In a restaurant, whenever customers visit, they are provided with items from two categories, one…
A: Answer: Algorithms 1.Given abstract class fixedCategory in this given bottle price and salad price…
Q: C++ is a programming language that can be used to Make a program that calculates the volume of…
A: C++ Program: #include <iostream>using namespace std; // Make a constant for piconst float pi =…
Q: rewrite the following class code to make employeeType as an abstract class, if you know that both…
A: In C++, an abstract class is one that contains one or more than one pure virtual function (a…
Q: Define an abstrat super class called Employee that contains a name (String), a social security…
A: class person { private String name; person(String s) {…
Q: Consider the following class definition that represents an AM radio class Radio { public bool…
A: Given: Consider the following class definition that represents an AM radio class Radio { public…
Q: 4. In a restaurant, whenever customers visit, they are provided with items from two categories, one…
A: import java.util.*; //defining abstract class abstract class fixedCategory{ double…
Q: Define two class types: Student and Graduate, where Graduate inherits from St udent. Class Student…
A: Sample Response: //C++ programming language//Tested on CodeBlock IDE#include <iostream>using…
Q: Suppose we're in a class called Vitamin and we have a private member variable named dosage of type…
A: Getter function is used to make secure our data and it returns the value of accessors. It start with…
Q: Define a class
A:
Q: If class A inherits class B and class C as "class A: private class B, public class C {// class…
A: This question comes from Object Oriented Programming which is a paper of Computer Engineering. Let's…
Q: Write a java program to create a class named shape. In this class we have three sub classes sphere,…
A: Write a java program to create a class named shape. In this class we have three sub classes sphere,…
Q: Suppose you want to have a Shipper class that implements the Comparable interface so that you can…
A: C. public class Shipper implements Comparable<Shipper>
Q: Using the information given above, create the following three classes. a. A parent class named…
A: C++ Code: #include <iostream>using namespace std; class Person{ private: string…
Q: Write an abstract class Shape with a pure virtual function Area to calculate the area shape. The…
A: We need to define the Shape, Circle, Triangle, Square classes as per the given description.
Q: When would you utilize an abstract class? when you require a super class that shouldn't be…
A: An abstract class can be defined as a class that is not supposed to have objects of it's own. The…
Q: write a phyton code: 1- define a class CommissionEmployee that: a. has a firstName, lastName,…
A: Here you go:
Q: Q2. Write the definition of class Example as follows: 1. Three private instance variables x, y and…
A: Need to write Java program with following implementations : Define Example class with : 1. Three…
Q: C++ QUESTION 2. Give a definition for a class InternationalStudent that is a derived class of the…
A: The answer is as follows.
Q: Write a class called quadratic that is derived from linear class to represents a quadratic equation…
A: The standard form of quadratic equation is cx^2+bx+a=0.Here, a, b and c are coefficients and 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: Consider the following class definition class father { protected : int age; public; father (int x)…
A: Given: Consider the following class definition class father { protected : int age; public; father…
Q: If class A inherits class B and class C as "class A: private class B, public class C {// class…
A: Inheritance is defined as the method of basing a class with another class as part of deriving new…
Q: Assume that class Item has following two private data fields: private String name; private…
A: Given: Assume that class Item has following two private data fields: private String name;…
Q: Write a program that defines a class Employce with the following members as shown in the bellow UML…
A: print method will print all the information like name, id, salary
Q: Create a class, Ring, that is a subclass of Circle. Additional property is the inner radius of…
A: Program Approach: Define the super class named Circle. Define the subclass named Ring. Define the…
Q: Use the concept of polymorphism and classes to represent the following analogy: A Transportation…
A: public class Transportation { //declaring instance variables private String model; private int…
Q: Write down code that can declare a class of an employee with the properties, name and salary, and…
A: I give the code in java as per your requirements and also give the output and code screenshot
Q: Q4. In a restaurant, whenever customers visit, they are provided with items from two categories, one…
A: Source codeBattery classpackage com.company;public class Battery { //instance variable…
Q: Define a class named Employee whose objects are records for employees. Derive this class from the…
A: Note: since programming language is not mentioned we are providing solution in c++. please repost…
Q: C++ is a programming language that can be used to Make a program that calculates the volume of…
A: Ans: Code: #include <iostream> using namespace std;class Cylinder { float r, h; public :…
Q: A complex number has the form a+bi ,can be expressed as the ordered pair of real numbers…
A: Since, programming language is not mentioned in the question, we will answer this question in C++…
Q: Given the following partial class definition: public class A1 { public int x; private int y;…
A: Subclass: A class is said to be a subclass of another class if it is derived from that class. For…
Q: Consider the following code and write the complete definition of the mentioned class according to…
A: Code: #include <iostream>#include<string>using namespace std;class Employee{//class…
Q: QUESTION 9 Consider the following class definition: public class SomeClass { private int a; public…
A: The question is regarding the inheritance. Whenever we extend a class for another class, in Java,…
Q: Write a class definition that creates a class called leverage with one private data member, crowbar,…
A: PROGRAM CODE: class leverage // start definition of class leverage{…
Q: Suppose in Islamabad International Airport the plans arrivals and departures are frequent and they…
A: Program code: //C++ program to computes the kinetic energy#include <iostream>using namespace…
Q: Consider a base class named Employee and its derived classes HourlyEmployee and PermanentEmployee…
A: Code: #include <iostream> using namespace std; // class BankAccount class BankAccount{…
Q: Define a class called Cylinder that has the dimensions 'radius' and 'height' as its data members.…
A: // Code #include <iostream>#include <cmath>using namespace std; class Cylinder {…
Q: Q4. In a restaurant, whenever customers visit, they are provided with items from two categories, one…
A: import java.util.*; //defining abstract class abstract class fixedCategory{ double…
Q: Consider the following class declarations in C++: class C { protected: int x; public: void f(){...};…
A: the class hierarchy
Q: Write the following four classes to practice using an abstract class and polymorphism. Submit all…
A: The following points can be followed to create the mentioned four classes: Use abstract keyword to…
Q: Consider a class "Fan" with two integer data members, "state" (0/1 i.e. on or off) and "speed". 1.…
A: UML class diagram of Fan class: Where state and speed are private data members of fan class. The…
Q: Q 1. Consider the following class definition class father { protected : int age; public; father (int…
A: Given:
Q: th are not equal. The criteria should be, if the compared animals can swim or can fly then they are…
A: Consider the class in part a, and overload the equal-to operator (==) in the Animal class.…
Q: Assume that class Item has following two private data fields: private String name; private int code;…
A: Here in super class Item we have only one Constructor that takes two argument String n and int c.…
Give a definition for a class SmartBut that is a derived class of the base class
Smart given in the following. Do not bother with #include directives or
namespace details.
class Smart
{
public:
Smart( );
void printAnswer( ) const;
protected:
int a;
int b;
};
This class should have an additional data field, crazy, of type bool; one
additional member function that takes no arguments and returns a value of type bool; and suitable constructors. The new function is named isCrazy. You do not need to give any implementations, just the class definition.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Write a class definition that creates a class called leverage with one private data member, crowbar, of type int and one public function whose declaration is void pry(). Opp JavaImplement the following concepts by constructing suitable classes in Java -a. Constructorsb. Constructor Overloadingc. Function Overloadingd. Function Overridinge. InheritanceCreate a class Person - Field - Name, Birthdate, Contact no and Mail idMethods - Constructor, accept and displayClass Employee - Inherits the Person classFields : Emp ID, grade, basic salary, Gross Salary, HRA (House Rent Allowance), TA (TravelingAllowance), DA (Dearness Allowance)Given:Grade Basic TAA 8000 2000B 7000 1500C 6000 1000D 5000 500Calculate Gross Salary :Gross Salary = Basic + HRA (20% of Basic) + DA (50% Basic) + TAe.g if Basic = 8000TA = 2000HRA = 20% of 8000 = 1600DA = 50 % of 8000 = 4000Gross = 8000 + 2000 + 1600 + 4000 = 15600Optional : you can implement increment function in which you can change grade of an employee andrecalculate salary with new gradeConsider a class BankAccount that has • Two attributes i.e. accountID and balance and• A function named balanceInquiry() to get information about the current amount in the account Derive two classes from the BankAccount class i.e. CurrentAccount and the SavingsAccount. Both classes (CurrentAccount and SavingsAccount) inherit all attributes/behaviors from the BankAccount class. In addition, followings are required to be the part of both classes• Appropriate constructors to initialize data fields of base class• A function named amountWithdrawn(amount) to withdraw certain amount while taken into account the following conditionso While withdrawing from current account, the minimum balance should not decrease Rs. 5000o While withdrawing from savings account, the minimum balance should not decrease Rs. 10,000• amountDeposit(amount) to deposit amount in the accountIn the main() function, create instances of derived classes (i.e. CurrentAccount and SavingsAccount) and invoke their respective…
- Consider a base class named Employee and its derived classes HourlyEmployee and PermanentEmployee while taking into account the following criteria.• Employee class has two data fields i.e. a name (of type string) and specific empID (of type integer)• Both classes (HourlyEmployee and PermanentEmployee) have an attribute named hourlyIncome• Both classes (HourlyEmployee and PermanentEmployee) have three-argumentconstructor to initialize the hourlyIncome as well as data fields of the base class• Class HourlyEmployee has a function named calculate_the_hourly_income to calculate the income of an employee for the actual number of hours he or she worked. One hour income is Rs. 150 • Similarly, PermanentEmployee class has function named calculate_the_income to calculate the income of an employee that gets paid the salary for exact 240 hours, no matter how many actual hours he or she worked. Again, one hour salary is Rs. 150.Implement all class definitions with their respective constructors to…Consider the definition of the following class: public class CC { private int u; private int v; private double w; public CC( ) //Line 1 {…} public CC(int a) //Line 2 {…} public CC(int a, int b) //Line 3 {…} public CC(int a, int b, double d) //Line 4 {…} A. Give the line number containing the constructor that is executed in each of the following declarations: (i) CC one = new CC( ); _________________ (ii) CC two = new CC(5, 6); _________________ (iii) CC three = new CC(2, 8, 3.5); _________________ B. Write the definition of the constructor in Line 1 so that the instance variables are initialized to 0. C.Write the definition of the constructor in Line 4 so that the instance variables u, v, and w are initialized according to the values of the parameters a, b, and d,…Write a class definition that creates a class called leverage with one private data member, crowbar, of type int and one public function whose declaration is void pry().
- C++ is a programming language that can be used to Make a program that calculates the volume of different containers. Cylinder will be the base class, and its derived classes, also known as child classes or sub-classes, will be constructed. Create a parent class, Cylinder, first. Make a constant for pi, as you'll need it for any containers that aren't square. For the members, use protected. Finally, add a public function to control the volume. V = pi * (r2) * h is the formula.Create a program that has the following classes: Point - Just like in the lecture, with attributes x and y set to 0 by default. Circle - Contains two attributes, center and radius. center is of type Point defined above (initialize a Point instance for this), while radius is set to 0 by default. The program must have the function point_in_circle(c, p) where c is a Circle and p is a Point. The function returns True if the point is within the circle, and False otherwise. You may use the math module (and nothing else) if necessary. You may also create other functions that can help you code the main function much easier. Example usage # Initialize a circle with center at (0, 0) and radius 1 (unit circle). c = Circle() c.center.x, c.center.y, c.radius = 0, 0, 1 # Initialize a point located at (1, 1) p = Point() p.x, p.y = 1, 1 # This returns False since (1, 1) is outside the circle point_in_circle(c, p)Hi can you assist me on the problem below for a class and a test class that conforms to the following specifications: 1. The name of the class is RightTriangle 2. The class has member variables base and height 3. The class has a constructor that initializes base and height 4. The class has accessors and mutators for base and height 5. The class has a toString method that produces String representation of a RightTriangle like the following example for a triangle with base 12 and height 10. Base : 12 Height 10 6. The class has a method called findArea to compute the area of the right triangle. Here is a suggested implementation. public double findArea() { return 0.5* this.base*this.height; } 7. The class using proper naming conventions Write a test class called RightTriangleTest that conforms to the following: 1. Create an object with base = 10 and height = 20, for example myTriangle. 2. To print the toString for myTriangle. 3. To print the area of myTriangle. System.out.println(“The…
- Take this the Java Gringrots problem below turn it into a running program. where the main should find out how many galleons are from 100,000 knuts. : " Write a Java program using a class identified as Gringots.This Java class has a main, and the following protected member functions: Member function galleons2Sickles has an integer parameter value, and returns an integer value*17Member function sickles2galleons has an integer parameter value, and returns an integer value / 17Member function sickles2nuts has an integer parameter value, and returns an integer value*29Member function knuts2sickles has an integer parameter value, and returns an integer value/29 Member function Galleons2Knuts has an integer parameter value, and then uses member functions Galleons2Sickles and Sickles2Knuts to convert, and then returns the integer. Member function Knuts2Galleons has an integer parameter value, and then uses member functions Knuts2Sickles and Sickles2Galleons to convert, an dthen returns the…C++ QUESTION 2. Give a definition for a class InternationalStudent that is a derived class of the base class Student given in the following. Do not bother with #include directives or namespace details.class Student{public:Student( );void printInfo( ) const;protected:int id;string name;};This class InternationalStudent should have an additional data field nation of type string ; one additional member function isFunded that takes no arguments and returns a value of type bool ; and suitable constructors.You do not need to give any implementations, just the class definition.Write a class Distance which has two private data members (int feet,float inches). The class has three constructors which are having no parameter - values of both feet and inches are assigned zero. having two numbers as parameters - the two numbers are assigned as feet and inches respectively. having one number as parameter - both feet and inches are assigned that number. Provide getters and setters for data members. Now write a main class which demonstrate the functionality of above class by calling all constructors, setters & getters. Create 1 object using default constructor, and use setters to set values, then getters to print values. Create a second object using constructor having two parameters, provide values, then print values on screen. Create third object by using third constructor having one parameter, after that print values on screen.