C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
Expert Solution & Answer
Book Icon
Chapter 12, Problem 13SA

Explanation of Solution

The program execution is explained in the in-lined comments:

#include <iostream> 

#include <iomanip>

using namespace std; 

int main()  

{  

    //declare pointer variables and allocate memory

    double *trip1Cost = new double;

    double *trip2Cost = new double;

    double *trip3Cost = new double;

    double *max;

    //store values in the allocated memory 

    *trip1Cost = 100.00;

    *trip2Cost = 350.00;

    //assign pointer variables to each other

    //trip3Cost now points to location having 

    //stored 350.00 later trip2Cost points

    //to location having a stored value 100.00

    trip3Cost = trip2Cost;

    trip2Cost = trip1Cost;

    //trip1Cost is now pointed to freshly allocated

    //memory location and assigned value

    trip1Cost = new double;

    //trip1Cost points to a location having

    //stored value of 175 and trip3Cost now

    //points to a location having a stored value 275

    *trip1Cost = 175;

    *trip3Cost = 275;

    //sets the output format

    cout << fixed << showpoint << setprecision(2);

    //prints the arithmetic expression

    //(*trip1Cost + *trip2Cost + *trip3Cost) which

    //evaluates to (175 + 100...

Blurred answer
Students have asked these similar questions
C++ only. Do not copy. Correct code will upvoted else downvote.   Monocarp is playing a PC game. Presently he needs to finish the principal level of this game.    A level is a rectangular framework of 2 lines and n sections. Monocarp controls a character, what begins in cell (1,1) — at the convergence of the 1-st line and the 1-st segment.    Monocarp's character can move starting with one cell then onto the next in one stage if the cells are nearby by side or potentially corner. Officially, it is feasible to move from cell (x1,y1) to cell (x2,y2) in one stage if |x1−x2|≤1 and |y1−y2|≤1. Clearly, it is denied to go external the matrix.    There are traps in certain cells. In case Monocarp's character winds up in such a cell, he bites the dust, and the game closures.    To finish a level, Monocarp's character should arrive at cell (2,n) — at the crossing point of line 2 and section n.    Assist Monocarp with deciding whether it is feasible to finish the level.    Input    The principal…
C++ You are required to write three overloaded functions called stringOperation that take in the following formal parameters list: Function 1: takes as input a string, ONE character, and an integer n, and returns true if the string contains that character EXACTLY an n number of times. Function 2: takes as input a string and TWO alphabatical characters c1 and c2, and returns true if all the string characters fall in the range between the two passed characters (exclusive) (You must make sure to order the characters first if c2 < c1 ). Function 3: takes as input a string and THREE alphabatical characters c1, c2 and c3. The function reorders the characters in asecnding order, such that c1 holds the smallest character and c3 holds the largest character. The function returns true if the string characters that fall between c1 and c2 (exclusive) is less than the string characters that fall between c2 and c3 (exclusive). Do not write and submit the main subroutine, or any include…
Code using c++ 3. From Person to People by CodeChum Admin Now that we have created a Person, it's time to create more Person and this tech universe shall be filled with people!     Instructions: In the code editor, you are provided with the definition of a struct Person. This struct needs an integer value for its age and character value for its gender. Furthermore, you are provided with a displayPerson() function which accepts a struct Person as its parameter. In the main() function, there's a pre-created array of 5 Persons. Your task is to ask the user for the values of the age and gender of these Persons. Then, once you've set their ages and genders, call the displayPerson() function and pass them one by one. Input 1. A series of ages and genders of the 5 Persons Output Person·#1 Enter·Person's·age:·24 Enter·Person's·gender:·M   Person·#2 Enter·Person's·age:·21 Enter·Person's·gender:·F   Person·#3 Enter·Person's·age:·22 Enter·Person's·gender:·F   Person·#4…
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education