Write code that docs the following:
• Uses a lambda expression that accepts two int arguments, a and b, and returns the value of a * b.
• Assigns the lambda expression to a variable named multiply.
• Uses the multiply variable to call the lambda expression, passing the values 2 and 10 as arguments. The result should be assigned to an int variable named product.
Want to see the full answer?
Check out a sample textbook solutionChapter 17 Solutions
STARTING OUT WITH C++FROM CONTROL STRU
Additional Engineering Textbook Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out with Programming Logic and Design (4th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Starting Out with Java: Early Objects (6th Edition)
- Create a class called Date that includes three pieces of information as data members—a month (type int ), a day (type int ) and a year (type int ). Your class should have a constructor with three parameters that uses the parameters to initialize the three data members. For the purpose of this exercise, assume that the values provided for the year and day are correct, but ensure that the month value is in the range 1–12; if it isn’t, set the month to 1. Provide a set and a get function for each data member. Provide a member function displayDate that displays the month, day and year separated by forward slashes ( / ). Write a test program that demonstrates class Date ’s capabilities.arrow_forwardWrite a program in java a class Box having three private data members (width, depth, height) The class has three constructors which are having no parameter – for setting values to zero or null. having three parameters for assigning values to height, width, depth respectively. Overload the above constructor and use this keyword to set the values of width, height & depth. Provide getters/setters for data members. Write a function calculateVolume() which calculates the volume of the box. Write test Application that demonstrates the Box class by calling all the three constructors and method, creating a Create Box object, and then displaying the Box’s width , height, length and volumearrow_forwardC++YOU ONLY NEED TO EDIT date.h, dateOFYear.h, and dateOFYear.cpp date.h | date.cpp | dateOfYear.h | dateOfYear.cpp | dateTest.cpp You have been provided a Date class. Each date contains day and month parameters, a default and a custom constructor, mutator and accessor functions for the parameters, and input and output functions called within operator >> and <<. You will be writing a DateOfYear class, which expands on the Date class by adding a year parameter. This will be achieved via inheritance – DateOfYear is the derived class of the Date base class. In DateOfYear, will need to write… The include guards for the class A default constructor that initializes all parameters to 1 A custom constructor that takes in a month, day, and year to initialize the parameters Mutator and accessor for the year parameter Redefined versions of inputDate and outputDate that takes into account the new year parameter. The driver program, dateTest.cpp, is already set for use with both Date…arrow_forward
- (C++) Create a class Cylinder with attributes base-radius and height, each of which defaults to 1 .Provide member functions that calculate the surface area ( = 2πrh) and the volume (= πr2h) of the cylinder. Also, provide set and get functions for the base radius and height attributes. The set functions should verify that base radius and height are each floating- point numbers larger than 0.0 and less than 20.0. Use M PI from < cmath > header for π.arrow_forwardWrite a code in Java for the following: Include a header that is Your Name, Target Heart Rate Include a text box to allow the user to enter their age Include a label for the text box that is "Your Age" Include a button to allow the user to calculate their Target Heart Rate range Include an element (or elements) to display the calculated Target Heart Rate range The element should display (or include a label) stating "Target Heart Rate: " Include a JavaScript function (or functions) to do the following: Calculate the user's maximum heart rate (maxHR) Store the user's maximum heart rate in a variable Calculate the user's minimum target heart rate (minTHR) using the formula minTHR = maxHR * .5 Calculate the user's maximum target heart rate (maxTHR) using the formula maxTHR = maxHR * .85 Display the calculated minimum and maximum target heart rate values using the format "minTHR to maxTHR Beats Per Minute" (NOTE: include only the integer portion of the min and max target values by using…arrow_forwardYou are developing a Fraction structure for Teacher’s Pet Software. The structure contains three public data fields for whole number, numerator, and denominator. Using the same structure, write the functions described below: • An enterFractionValue()function that declares a local Fraction object and prompts the user to enter values for the Fraction. Do not allow the user to enter a value of 0 for the denominator of any Fraction; continue to prompt the user for a denominator value until a valid one is entered. The function returns a data-filled Fraction object to the calling function. • A reduceFraction()function that accepts a Fraction object and reduces it to proper form, returning the reduced Fraction. For example, a Fraction entering the function as 0 2/6 would be reduced to 0 1/3, and a Fraction entered as 4 18/4 would be reduced to 8 1/2. • A displayFraction()function that displays any Fraction object passed to it. This function displays a fraction with a slash between the…arrow_forward
- Can you help me please: 2. Consider the following statements: class temporary { public: void set(string, double, double); void print(); double manipulate(); void get(string&, double&, double&); void setDescription(string); void setFirst(double); void setSecond(double); string getDescription() const; double getFirst()const; double getSecond()const; temporary(string = "", double = 0.0, double = 0.0); private: string description; double first; double second; }; Now answer the following questions: a. Write the definition of the member function set so that the instance variables are set according to the parameters. b. Write the definition of the member function manipulate that returns a decimal number as follows: If the value of description is "rectangle", it returns first * second; if the value of description is "circle", it returns the area of the circle with radius first; if the value of description is "sphere", it returns the volume of the sphere with radius first; if the…arrow_forwardC++ program Hi i need help making the following function, ------>>>>>> friend bool operator<(Date& date1, Date& date2); the function is supposed to compare 2 date objects of the Date class ............................... It is supposed to overload the < operator to compare 2 Date objects. The comparison shall return true only if the Date object on the left represents a date earlier than the Date object on the right. The comparison shall not update either Date object. please help I provided all my code below: The following are the 3 libraries of my program --------------------------------------------------------------------------------------------------------------------------------------------------------- DATE.H file: #ifndef DATE_H#define DATE_H#include <string>using namespace std; class Date { private: string entered_date; int month_, day_, year_; public: Date(); Date(const string& entered_date); friend bool…arrow_forwardCreate a class called complex for performing arithmetic operations with complex numbers. Use floating point variables to represent the private data of the class. Provide a default constructor that initializes the object with default values to -1. Provide public member functions for each of the following: • Addition of two complex numbers: It returns the result obtained by adding the respective real parts and the imaginary parts of the two complex numbers. (Return the object) • Subtraction of two complex numbers: It returns the result obtained by subtracting the respective real parts and the imaginary parts of the two complex numbers. (Return the object) • display(complex object) – It displays the complex number in a+bi format. The output should be displayed as follows:- Sum of a1+b1 i & a2+b2 i is : a3+b3arrow_forward
- Please answer in C++ / Text book question / C++ for scientist and Engineers 3rd edition Construct a class named Fractions containing two integer data members named num and denom, used to store the numerator and denominator of a fraction having the form num/denom. Your class should include a default constructor that initializes num and denom to 1 and four operator functions for adding, subtracting, multiplying, and dividing the two fractions, as follows: Addition: a/b + c/d = (a * d + b * c) / (b * d)Subtraction: a/b - c/d = (a * d - b * c) / (b * d)Multiplication: a/b * c/d = (a* c) / (b * d)Division: (a/b) / (c/d) = (a * d) / (b * c) Finally, your class should have a member function that reduces each fraction to its terms (refer to Exercise 15 in Programming Projects for Chapter 6 for how to do this) as well as input and output functions for entering and displaying a fraction. thanksarrow_forwardHello.. i hope you are well. please code this for me in java and follow the instructions mentioned as it is Write code that uses lambdas and streams to satisfy the requirements listed below. Print a list of all employees that earn $50,000 or more:Print a list of the names (not the Employee instances) of all employees who were hired on or after Jan. 1, 2012.Print the maximum salary of all employees.Print the minimum salary of all employeesNow, print the average salary of all Female and Male employees:Finally, use the reduce() operation to find the Employee instance of the employee with the highest salary:arrow_forwardC++ please Write a driver function definition called add that takes as its parameters two FractionType objects. The driver function should add two fractions together and return a FractionType object. Remember that the denominators of fractions cannot be 0. (Hint: validate each fraction before performing the addition operation. Also, do not to reduce the FractionType object to its simplest form.)arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT