Part (1) Define a class with the following specification: a. Create a class called Employee that has four instance variables - a (String) first name, a (double) payRate, a (double) normalHours, and a (double) extraHours. b. Make the instance variable payRate private and provide a mutator method (set) and an accessor method (get) to access this variable. In set method, if the supplied pay rate (parameter) is negative print an invalid message and do not change the instance variable payRate. A method calcPay() to calculate the employee pay by multiplying payRate by normalHours added to it the pay for extraHours. For every extra hour the pay rate is doubled. This method must return the pay as a result. d. A method print() that displays the normal and extra working hours and the calculated pay amount formatted to two decimal places as shown below. C.
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: Consider the following class Date, which represents a date using three ints for month, day and year:…
A: bool Date::operator==(Date d){ if (month == d.month && day == d.day && year ==…
Q: 5.Do we need any "static" method/variable inside of a singleton class? Explain briefly with proper…
A: NOTE:“Since you have asked multiple questions, we will solve the first question for you. If you want…
Q: 12) Consider that you want to extend AClass to BClass. BClass will have a third int instance data,…
A: According to the question below the Answer:
Q: c) Suppose we have a class User which has a constructor with the header User (String name, Account…
A: In this question we have given a user class which has a constructor with the header User( string…
Q: Problem B Now we are going to use the design pattern for collecting objects. We are going to create…
A: Code: import java.util.ArrayList; class AmazonOrder{ final int length=5; ArrayList<Item>…
Q: 9 Implement the following constructor. The class has two attributes: rank and suit. Make sure the…
A: NOTE: - The programming language is not mentioned, so below code is done in JAVA. The card class has…
Q: Task – 10 Implement the design of the CSE and EEE classes that are derived from the Department class…
A: Here I have created 2 child classes that extend the Department class. In these child classes, I…
Q: Write a program to use Friend function within three classes. The classes are pk901, pk902, pk903 and…
A: A friend function is a special function that can access the private members of a class as though it…
Q: This lab will exercise your understanding of some of the concepts covered in Chapter 13:overloading…
A: Program Approach: Importing the essential headers and using the namespace std. Creating a class…
Q: This chapter uses the class rectangleType to illustrate how to overload the operators +, *, ==, !=,…
A: The answer given as below:·
Q: Suppose Truck and Motorcycle are subclasses of Vehicle. Which of these declarations are invalid? =…
A: Introduction of the Program: In java, we can not assign the base class object in the derived class…
Q: Part (1) Define a class with the following specification: a. Create a class called Employee that has…
A: Class in java: Everything in Java is associated with classes and objects, along with its attributes…
Q: 2 a) Suppose that two methods are defined in a same class. One method is static and another one is…
A: A. REASON - It is not possible to call directly a non static method from a static method , because…
Q: al operators as defined in parts 1 to 3. Overload the pre- and post-increment and decrement…
A: the code is an given below :
Q: B: Write the definition of class Example2 that inherits Example as follows 1. one instance variables…
A: Inheritance is a technique of Object Oriented Programming, which allows the child class to inherit…
Q: Suggest a simple scheme for creating a new class SafeMember that would allow us to export a…
A: Given: Suggest a simple scheme for creating a new class SafeMember that would allow us to export a…
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: Write a program to model a student class with roll number and name as the sensitive information.…
A: PROGRAM CODE: import java.util.*; // import required librariesclass student{…
Q: 4. If B is a subclass of class A. Given the following object: A a = new B0: Which of the following…
A: The correct answer option is provided below with explanation.
Q: Let B be a class with a constructor that can receive an int as its parameter_
A: Given :- In the above given question, a code or statement is mention in the above given question…
Q: a new class SafeMember that would allow us to export a reference to a Member. The classes outside…
A: Suggest a simple scheme for creating a new class SafeMember that would allow us to export a…
Q: uggest a simple scheme for creating a new class SafeMember that would allow us to export a reference…
A: solution:
Q: ) Consider a class Name, which has four instance data (all Strings): first, middle, last and title.…
A: please see the next step for solution
Q: 1. Based on the below UML diagram, write the implementation code to represent each class? 2. in the…
A: Below is the required C sharp program. Program Approach: Define a class as Dog. Inside the dog…
Q: 2. Consider the BlackJackCard and PlayingCard classes. a)Do these two classes have an…
A: As per our guidelines, we are supposed to answer only 1st three parts. Kindly repost the remaining…
Q: Create the first Apex class or program -- In this apex class, we have to create 2 methods -- In the…
A: Required: Create the first Apex class or program-- In this apex class, we have to create 2…
Q: Write a class to define employee... with the following attributes:1- name 2- age 3- salary. and…
A: The question asks that build a class named employee with three attributes. name, age, salary. then,…
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: Write the definition of the default constructor of YClass so that the instance variables of YClass…
A: public YClass() { this.a=0; this.b=0; }
Q: please solve in python languange and use proper comments for better understanding . Thank you.
A: Given python code
Q: d an argument of type int in that interface. Build a class with name Bill that implements the above…
A: Q1) Write the Code the following scenario. Write an abstract function named receivePay in interface…
Q: Consider the following declarations: (1, 2, 5, 7) How many members does class foodType have?…
A: Note: since your question contain multiple sub-part but we can answer only 3 sub-part at time due to…
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: Refer to Example Code Ch 09-6: The reference to getMoney() in assignment 2 is to the class a. Person…
A: I have provided solution in step2.
Q: Q2: A: Write the definition of class Example as follows: 1. Three public instance variables x, y and…
A: Note: Answering in python as no language is mentioned. Define class Example with the following data…
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: uggest a simple scheme for creating a new class SafeMember that would allow us to export a reference…
A: Scheme: Many accessor methods need to return values which are references to objects which represent…
Q: Assume that Student, Employee and Retired are all extended classes of Person, and all four classes…
A: Person p = new Person(...);int m1 = p.getMoney(); // assignment 1 this is for person class p = new…
Q: Consider the definition of the following class: public class CC { private int u;…
A: Constructor is a special method that has the same name as the class name. The constructor method…
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: Part (1) Define a class as follow: a. create a class called Student that has four instance variables…
A: Program Screenshot: Program: class Student{ String name; long StudentID; String College; double…
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: In the below code I get the following error when running the test for verifying of stored private…
A: PYTHON : tHE _init_ method is similar to constructorsin C++ and Java. Constructors are used to…
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- Consider the above scenario, where Billing class has composition relationship with Doctor having private instance variables (docName, docID and docFee) and a public getDocID() method, Patient having private instance variables (pName, pID, pDisease), Medicine having private instance variables (medID, medName, medQty, medPrice), and MedicalTest having private instance variables (testID, testName, testPrice). In addition, each class shall have toString method to display its object state. Also define getDocInfo method in Billing class that shall return the doctor. Implement getPaymentAmount() method in Billing class that shall return the total billing amount that includes doctor fee, medicine cost and medical tests fee. Considering the above scenario, write code that shall perform the following in the driver/test class: Get an amount from user. Traverse the ArrayList<Billing> using enhanced for loop. Print the billing details of those bills having total billing amount greater or…Q2: Consider the following statements: public class YClass { private int a; private int b; public void one() { } public void two(int x, int y); { } public YClass() { } } class XClass extends YClass { private int z; public void one() { } public XClass() { } } YClass yObject; XClass xObject; Write the definition of the default constructor of YClass so that the instance variables of YClass are initialized to 0. Write the definition of the default constructor of XClass so that the instance variables of XClass are initialized to 0. Write the definition of the method two of YClass so that the instance variable a is initialized to the value of the first parameter of two and the instance variable b is initialized to the value of the second parameter of two. please I want solution :(Problem B Now we are going to use the design pattern for collecting objects. We are going to create two classes, a class AmazonOrder that models Amazon orders and a class Item that models items in Amazon orders. An item has a name and a price, and the name is unique. The Item class has a constructor that takes name and price, in that order. The class also has getters and setters for the instance variables. This is the design pattern for managing properties of objects. The setName() method should do nothing if the parameter is the empty string, and the setPrice() method should do nothing if the parameter is not positive. The class also has a toString() method that returns a string representation for the item in the format “Item[Name:iPad,Price:399.99]”. For simplicity, we assume an Amazon order can have at most 5 items, and class AmazonOrder has two instance variables, an array of Item with a length of 5 and an integer numOfItems to keep track of the number of items in the…
- 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)Consider the following code snippet. 1. /* 2. * The Student class models a student with a name, age 3. * and a faculty in which is currently enrolled in. 4. */ 5. public class Student 6. { 7. // private instance variable, not accessible from outside this class 8. private String firstName; 9. private String lastName; 10. private int birthYear; 11. private String faculty; 12. 13. // The constructor with the. correspondent parameters. 14. public Student(String first, String last, int birthYear, String faculty) 15. { 16. this.firstName= first; 17. this.lastName = last; 18. this.birthYear = birthYear; 19. this.faculty = faculty; 20. } 21. } 1. Implement an accessor method that returns the age of the student given as parameter the current year. 2. Implement a new method called printDetails, taking the currentYear as a parameter, that prints the full name, age and faculty of the student in the following way: Full name: Donald Duck Age: 24 years Faculty:…Consider the following program which contains a class definition currently missing one line of code: class Pokemon: def __init__(self, pokemon_name): ██████ pikachu_name = 'Pikachu' pikachu = Pokemon(pikachu_name) print(pikachu.name) Suppose that we want the constructor of this class to initially set the value of the instance variable name based on its arguments. This implies that the expected output of the program is 'Pikachu'. What should the missing line of code be? a. name = pokemon_name b. name = pikachu_name c. pikachu.name = pikachu_name d. self.name = pokemon_name e. pikachu.name = pokemon_name f. self.name = pikachu_name
- Part (1) Define a class with the following specification:a. Create a class called Employee that has four instance variables – a (String) first name, a (double) payRate, a(double) normalHours, and a (double) extraHours.b. Make the instance variable payRate private and provide a mutator method (set) and an accessor method(get) to access this variable. In set method, if the supplied pay rate (parameter) is negative print an invalidmessage and do not change the instance variable payRate.c. A method calcPay() to calculate the employee pay by multiplying payRate by normalHours added to it the payfor extraHours. For every extra hour the pay rate is doubled. This method must return the pay as a result.d. A method print() that displays the normal and extra working hours and the calculated pay amount formattedto two decimal places as shown below.Sample Output:Employee Name: AhmedNormal Hours Worked: 140.00Extra Hours Worked: 20.00Hourly Rate: $ 2.50Pay Amount: $ 450.00 Part (2) Write a Java…This chapter uses the class rectangleType to illustrate how to overload the operators +, *, ==, !=, >>, and <<. In this exercise, first redefine the class rectangleType by declaring the instance variables as protected and then overload additional operators as defined in parts 1 to 3. Overload the pre- and post-increment and decrement operators to increment and decrement, respectively, the length and width of a rectangle by one unit. (Note that after decrementing the length and width, they must be positive.) Overload the binary operator – to subtract the dimensions of one rectangle from the corresponding dimensions of another rectangle. If the resulting dimensions are not positive, output an appropriate message and do not perform the operation. The operators == and != are overloaded by considering the lengths and widths of rectangles. Redefine the functions to overload the relational operator by considering the areas of rectangles as follows: Two rectangles are the…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 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…This chapter uses the class rectangleType to illustrate how to overload the operators +, *, ==, !=, >>, and <<. In this exercise, first redefine the class rectangleTypeby declaring the instance variables as protected and then overload additional operators as defined in parts 1 to 3. Overload the pre- and post-increment and decrement operators to increment and decrement, respectively, the length and width of a rectangle by one unit. (Note that after decrementing the length and width, they must be positive.) Overload the binary operator – to subtract the dimensions of one rectangle from the corresponding dimensions of another rectangle. If the resulting dimensions are not positive, output an appropriate message and do not perform the operation. The operators == and != are overloaded by considering the lengths and widths of rectangles. Redefine the functions to overload the relational operator by considering the areas of rectangles as follows: Two rectangles are the…Problem 1: Complete a properly encapsulated class named Shape, which has the following: -A Boolean instance variable named is Filled . -A String instance variable named color. - A default, no-arg constructor which sets isFilledto true, and colorto “Green”. -An overloaded constructor which takes two parameters, a Boolean and a String and sets the instance variables accordingly. -An overridden toString() method, which returns a String. The String should contain: The values of the instance variables in the following format: Filled: true Color: Green