Concept explainers
The private member function DayOfYear::checkDate in Display 10.4 allows some illegal dates to get through, such as February 30. Redefine the member function DayOfYear::checkDate so that it ends the
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Problem Solving with C++ - MyProgrammingLab
Additional Engineering Textbook Solutions
C++ How to Program (10th Edition)
Digital Fundamentals (11th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out With Visual Basic (8th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out with Java: From Control Structures through Objects (6th Edition)
- In Kotlin, Use this Employee class: data class Employee(val name: String, val wage: Double, val hours: Double) and this list of Employees: val l: List = listOf(Employee("Bob", 34.33, 42.0), Employee ("Cathy", 27.33, 15.25), Employee("Carlos", 46.99, 38.75), Employee("Tomas", 49.66,28.45), Employee("Xavier", 34.56, 11.5)) a) Write a function called calcBracket that calculates an employee's tax withholding bracket this way: if the Employee's hourly wage is under 15 (in dollars per hour), the withholding bracket is 0; if the wage is at least $15 but under $25, the bracket is .15 (that is, 15%); if the wage is at least $25 but less than $35, the bracket is .25; if th wage is at least $35, the bracket is .35. Return the bracket. b) Write a function that l, takes a list of Employees and f, a function from Double to Double (don't write a call to calcBracket into this function - you will take it as a parameter called f and call f). This function returns a list of Pairs in which each…arrow_forwardCreate a class ‘Date’, with three private variables ‘day’, ‘month’, ‘year’. Write a no argument constructor to iniatilize date to 01/01/1900. Also writea three argument constructor Date (int day, int month, int year) to showconstructor overloading. Also create a destructor. Create two functions with following signatures:bool LeapYear (Date obj)Checking if the date is within a leap yearint SubstractDate (Date obj1, Date obj2)Subtracting two dates to give a number of days c++arrow_forwardA main() function is given below. Based on this function, your task is to write complete code required to run the main() function successfully. Class Rectangle{Private:int len;int width;static int objectCount;public:All functions that are needed. };int main(){int len;int width;cin>>len;cin>>width;Rectangle r1(len,width);Rectangle r2(4,6);Rectangle r3();Rectangle r4();Rectangle r5();r3 = r1 + r2;r4 = r1 - r2;r5 = r1 * r2;if(r3 == r4){cout<<"Both are equals"<<endl;}else if(r3 > r4){cout<<"r3 is greater than r4"<<endl;}else if(r3 < r4){cout<<"r4 is greater than r3"<<endl;} return 0;}arrow_forward
- Implement a class named Animal has two private member variables: name of type string and numLegs of type int, and has the following member functions: • setName—Function to set the name • setNumLegs—Function to set the number of animal legs • getName—Value-returning function to return the name • getNumLegs—Value-returning function to return the number of animal legs • speak()—Value-returning function to return the empty string • move()—Value-returning function to return the empty string • print()—Outputs the data stored in the instance variables with the appropriate titles • Constructor with parameter—Sets the values of the instance variables to the values specified by the user, in default: sets name to the empty string and number of legs to 0 2. Using an Animal class as a base class, implement two derived classes simulating a Cat and Dog, each redefining three functions constructor, speak(), move() to represent each animal the most suitable. 3. Write a function to handle the…arrow_forwardUsing object-oriented principles, write a C++ program that will analyze a year's worth of rainfall data. Within the class, create a private member function called getData that will read in the data from an input file called rain2019.txt. This file contains the total rainfall for each of the 12 months. Read the contents of this file into a float array. The class should have four private member functions that compute and return totalRainfall, averageRainfall, driestMonth, and wettestMonth. The last two private member functions return the number of the month with the lowest and highest rainfall amounts, not the amount of rain that fell in those months. Notice that the month number can be used to obtain the amount of rain that fell those months. Create a private member function called displayReport that will print a summary rainfall report similar to the following (NOTE: this is only an example of format, not accurate data): 2019 Rain Report for Alachua County Total rainfall: 34.19…arrow_forwardc++ Build a class Sale with private member variablesdouble itemCost; // Cost of the itemdouble taxRate; // Sales tax rateand functionality mentioned below:● Write a default constructor to set the member variable itemCost to 0 andtaxRate to 0. ● Write a parameterized constructor that accepts the parameter for eachmemberSale( double cost, double rate) ● Generate only accessors for itemCost and taxRate● Write a function double getTax( ) to calculate tax i.e take a product ofitemCost and itemRate. ● Write a function double getTotal( ) to calculate the total price of itemi.e. take a sum of itemCost and getTax( ) (calling getTax() will returnthe calculated tax on item).arrow_forward
- C++ Programming Use the following code, which could be added to your current file in CLion, so this code compiles and the assertion passes. This means you need to implement class AccountContainer. The member function getValue() must always return the sum of all BankAccounts. Do not hard code getValue to return 109.99. auto acct1 = shared_ptr(new RegularAccount("account", 100.00)); auto acct2 = shared_ptr(new RegularAccount("account", 9.99)); auto accounts = new AccountContainer(); accounts->add(acct1); accounts->add(acct2); assert(accounts->getValue() == 109.99);arrow_forwardReuse your Car class . In a main, build an object of that class, and print out the object using System.out.println(). Notice that this simply reports the memory address of the object in question, and we’d like to do something more useful. To replace (or override) the toString (or equals) function. Now, build a toString function that prints out the make, model, and odometer reading for a vehicle object. public class Car { //instance variables private int odometer; private String make; private String model; //overloading //constructors public Car(int odometer,String make, String model) { this.odometer = odometer; this.make = make; this.model = model; } public Car(String make, String model) { this.make = make; this.model = model; } public Car(String make) { this.make = make; } /* *getter & setter methods */ public int getOdometer() { return odometer; } public void…arrow_forwardImplement 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++arrow_forward
- write a class Point with parametrized constructor. This class have four member variables, a,b,c,d. Write the following member functions a. drawTriangle(int x, int y, int z ) b. drawRectangle(int x, int y, int z, int a). Each function should display the length of lines for each of the shape (triangle, rectangle). For example triangle should calculate length of its three lines by following methods as shown in code. Note: the number of lines depends on the name of shape. void drawTriangle(int x, int y, int z ) { int line 1 = x - y; // convert to positive value if line length is negative int line 2 = y -z; int line 3 = z -x; cout<< The length of each lines is: << //// here display length of each line with proper formatting. } Write similar code for drawRectangle(int x, int y, int z, int a). Wtite main function to call these three functionarrow_forwardWrite a code which contains a class CBookList with Private members: CBook books, int ListID. A constructor, which takes the above two arguments as input and assigns them to the class members. The constructor should also cater for default Getter and setter accessor functions for all PrintSome function which cout’s the details of the entire list of books in the particular PrintAll function which cout’s the details of the entire list of books in the entire A destructor. A function to add new nodes to the list, where each node is a CBook type object. Initial insertion should be done at the end of A sort function, that should be able to sort the entire list of books in ascending or descending order of their ID’s. Add and Delete functions to add lists and remove book DeleteAll function to remove all books starting from the head of thearrow_forwardUsing object-oriented principles, write a C++ program that will analyze a year's worth of rainfall data. Within the class, create a private member function called getData that will read in the data from an input file called rain2019.txt. This file contains the total rainfall for each of the 12 months. Read the contents of this file into a float array. The class should also have four private member functions that compute and return the totalRainfall, averageRainfall, driestMonth, and wettestMonth. The last two private member functions return the number of the month with the lowest and highest rainfall amounts, not the amount of rain that fell in those months. Notice that the month number can be used to obtain the amount of rain that fell those months. Create a private member function called displayReport that will print a summary rainfall report similar to the following 2019 Rain Report for X CountyTotal rainfall: 34.19 inchesAverage monthly rainfall: 2.85 inchesThe least…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education