Bartleby Sitemap - Textbook Solutions

All Textbook Solutions for C++ for Engineers and Scientists

9E10E11E12E13E14E1E2E3E4E5E6E7E8E9E(Program) Include the Date class definition in Class 11.1 in a complete program. Your program should verify that each member function works correctly.2E3E4E5E6E7E8E9E10E11E1E2E3E4E5E6E7E8E1PP2PP(Program) a. Complete the following class by including functions corresponding to the two prototypes listed in the declaration section: classElevatorprivate:intelNum;//elevatornumberintcurrentFloor;//currentfloorinthighestFloor;//highestfloorpublic:Elevator( int=1,int=1,int=15);//constructorvoidrequest( int);; In this definition, the data member elNum is used to store the elevator’s number, the data member currentFloor is used to store the elevator’s current floor position, and the data member highestFloor is used to store the highest floor the elevator can reach.The constructor should allow initialization of an object’s three data members with the data passed to the constructor when an Elevator object is instantiated. The request function should code the following algorithm: If a request is made for a nonexistent floor, a floor higher than the topmost floor, or the current floor Do nothing ElseIf the request is for a floor above the current floor Display the current floor number While not at the designated floor Increment the floor number Display the new floor number EndWhile Display the ending floor number Else // the request must be for a floor below the current floor Display the current floor number While not at the designated floor Decrement the floor number Display the new floor number EndWhile Display the ending floor number EndIf b. Include the class written for Exercise 3a in a complete program, and verify that all member functions work correctly.4PP5PP1E2E3E4E5E6E7E8E1E2E3E4E5E6E1E2E3E4E1E2E3E4E5E6E1E2E3E4E5E6E1PP(General math) a. Construct a class named Cartesian containing two double-precision data members named x and y, which will be used to store the x and y values of a point in rectangular coordinates. The member functions should include a constructor that initializes an object’s x and y values to 0 and functions to input and display an object’s x and y values. Additionally, include an assignment function that performs a memberwise assignment between two Cartesian objects. b. Include the class written for Exercise 2a in a working C++ program that creates and displays the values of two Cartesian objects; the second object is assigned the values of the first object.3PP4PP1E(Practice) For the data types declared in Exercise 1, define a suitable structure variable name, and initialize each structure with the following data: a.IdentificationNumber:4672NumberofCreditsCompleted:68GradePointAverage:3.01b.Name:RhonaKarpBirthDate:8/4/60NumberofCreditsCompleted:96GradePointAverage:3.89c.PartNumber:54002ICFamily:ECLFunctionType:NANDSupplyVoltage:5UnitsinStock:123d.StockName:IBMStockPrice:173.16DatePurchased:8/30/2011e.PartNumber:16879PartDescription:BatteryNumberinStock:10ReorderNumber:33E4E5E6E1E2E3E4E(Data processing) a. Declare a single structure data type suitable for a car structure of the type in the following chart: b. Using the data type declared for Exercise 5a, write a C++ program that interactively accepts the chart’s data in an array of five structures. After the data has been entered, the program should create a report listing each car number and the car’s miles per gallon. At the end of the report, include the average miles per gallon for the entire fleet of cars.1E2E3E4E1E2E3E4E5E1E2E3E4E5E6E1E2E3E4E5E1PP2PP3PP4PP5PP1E1E2E3E1E2E3E4E1E2E3E4E1E2E3E1E2E3E4E1PP2PP3PP4PP5PP
Page: [1][2][3]